invalid get index 'var' (on base: 'float')

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

Help This is the code that i use to store skins and i don’t know why it won’t load.

Image of the error

:bust_in_silhouette: Reply From: exuin

When you store your save data, you’re not storing it as json but you are trying to parse the saved data as json when you load it. Use the to_json() function on a dictionary in order to properly store the data.

Tried but now when i close the program both of the variables reset to 0 0 but the savefile remains 1 0


andrymas | 2021-01-07 18:52

Maybe it’s because you’re converting it to an int when the program has it as a float in the previous error message?

exuin | 2021-01-08 01:45

Still haven’t figured out the error but i’ve deleted that code and tried this one that works:

extends Node

var skin1own = 0
var skinequip = 0

var score_file = "user://"

func save_skin():
    var file =, File.WRITE)

func load_skin():
    var file =
    if file.file_exists(score_file):, File.READ)
	    skinequip = file.get_var()
	    skin1own = file.get_var()
	    skinequip = 0
	    skin1own = 0

andrymas | 2021-01-08 14:28