If you just need to save a variable or a dictionary this works fine (using it in my projects)
Everything in the “save” dictionary will be saved to the file, call the load_data to load it.
var save = {}
func save_data():
var file = File.new()
file.open("user://save",file.WRITE_READ)
file.store_var(save)
file.close()
func load_data():
var file = File.new()
if not file.file_exists("user://save"):
return false
file.open("user://save",file.READ)
save = file.get_var()
file.close()
check if the vaiable exist
func _ready():
if not save.has("item"):
save.item = {"worlds":{},"count":0}