func savedata(hs):
var hs_old=load_data()
if hs_old<hs:
var data={
highscore=hs
}
file.open(savePath,file.WRITE)
file.store_line(to_json(data))
file.close()
func load_data():
if file.file_exists(savePath):
file.open(savePath,file.READ)
var dict = {}
dict=parse_json(file.get_as_text())
file.close()
highscore = dict["highscore"]
print(highscore)
else:
var data={
highscore=0
}
file.open(savePath,file.WRITE)
file.store_line(to_json(data))
file.close()
return highscore
Have you been try to save your data to json file? Im using this for save and load highest score hope it can help, everytime player get higher score than before new highscore will replace it