Why does my saving not work

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamer78

This is the code I’m using to test saving in my game. I have tried it, but it does not work. What can I do to fix it? I get no errors or anything, so I don’t know what is wrong.

var game_data = {
“coins”: coins
}
func save_game():
var save = File.new()
save.open(“user://save_game.sav”, File.WRITE)
save.store_line(to_json(game_data))
save.close()
func load_save_file():
var save = File.new()
save.open(“user://save_game.sav”, File.READ)
var text = save.get_as_text()
game_data = parse_json(text)
save.close()

:bust_in_silhouette: Reply From: Hodor88

What Platform are you developing for? For mobile (Android) you might
Need privileges to Access storage.

Currently developing for Windows

Gamer78 | 2023-01-06 11:42

:bust_in_silhouette: Reply From: Hodor88

Looks Like its called to_json