This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I am trying to implement save/load data from a file following a tutorial ( but it fails. When I print the error, it just says 7. How can I know what error 7 means? This is the code:

onready var path = "user://save.dat"

func load_data():
var file =
var err =, File.READ)
if err != OK:
    print("error opening data file")
    return default_level_info       
var read = {}
read = file.get_var()
return read 
in Engine by (19 points)

1 Answer

+1 vote

To know what the error code means, check the Error enum documentation. 7 is for ERR_FILE_NOT_FOUND. To read a file, it needs to exist already. To create the file if it doesn't exist (and truncate it if it exists), use the File.WRITE mode instead of File.READ.

Call file_exists(path) from your File instance to check whether a file exists at the given path.

by (12,908 points)

Thank you so much, it worked exactly as you described.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.