My game don't save in the export version

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

Hi there.
For some reason my game don’t save when i export it.
in the console say this:

ERROR: File must be opened before use.
At: core/bind/core_bind.cpp:2245

The code for save:

extends Node


var BestScore = 0

var Save = {
	BS = null}
	
var saveFile = 1
var SDirectory  =  str("res://Saves/save", saveFile)	

onready var ExitPause = get_node("ExitPause")

func _ready():
	if load_data():
		thingsToLoad()	
	

func save_data():
	var file = File.new()
	file.open(SDirectory,file.WRITE_READ)
	thingsToSave()
	file.store_var(Save)
	file.close()
	
# and load
func load_data():
	var file = File.new()
	if not file.file_exists(SDirectory):
		return false
	file.open(SDirectory,file.READ)
	Save = file.get_var()
	file.close()
	return true
	
func thingsToSave():
	Save = {
		BS = BestScore
		}
	
func thingsToLoad():
	BestScore = Save.BS

Player function that saves:

func dead():
	Gv.save_data()
	var _RC = get_tree().reload_current_scene()
:bust_in_silhouette: Reply From: whiteshampoo

You need to use user:// instead of res://

You can read here why.

Still doesn’t work :frowning:

X | 2021-04-04 14:56

Is it the same error?

whiteshampoo | 2021-04-04 15:45

yes, but know it not even give me the error

X | 2021-04-04 21:13

You have to give us more information…

whiteshampoo | 2021-04-05 07:03