how can i save bool

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

hello, im making 2d game, and i dont know how can i save bool variable, i save float var like this

var file =
line_text = file.get_line()“res://scenes/save.txt”, file.WRITE)

:bust_in_silhouette: Reply From: timothybrentwood

You are looking for var2str() and str2var(). Search for “Saving data that exists solely in Godot” for an example of how to use them from GDQuest’s website:

Thanks, but i didnt understanded how it works, i changed variable from bool to float
0 = false
1 = true

Ktotoetoia | 2021-12-19 12:18

I did it one more time and it works, thanks

Ktotoetoia | 2021-12-19 12:28

In Godot4 you can do this:

var file =“user://save.dat”, FileAccess.WRITE)

To load use:

var file =“user://save.dat”, FileAccess.READ)
your_bool_var_name = file.get_var(your_bool_var_name)