0 votes

I tried my best to follow the documentation online. Here is what I have:

func save_high_score(high_score):
var path = "user://HighScore.dat"
var file = File.new()
file.open(path, File.WRTIE)

func load_high_score():
var path = "user://HighScore.dat"
var high_score = 0
var file = File.new()
if file.file_exists(path):
    file.open(path, File.READ)
    high_score = int(file.get_as_text())
return high_score

I'm not really getting a helpful error message, just that the game crashes when the savehighscore function is called. Thanks in advance for any help!

EDIT: I wasn't clear about this before, but the load function appears to function correctly, just not the save one.

EDIT 2: I am just dumb lol. I misspelled WRITE as WRTIE. Everything works now lol.

Godot version 3.5.1.stable.mono.official
in Engine by (30 points)
edited by

1 Answer

+1 vote
Best answer

Misspelled WRITE as WRTIE.

by (30 points)
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.