Attention | Topic was automatically imported from the old Question2Answer platform. | |
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()