What am I doing wrong? - Creating, Saving, and Reading Files

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

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)
file.store_string(str(high_score))
file.close()

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())
	file.close()
return high_score

I’m not really getting a helpful error message, just that the game crashes when the save_high_score 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.

:bust_in_silhouette: Reply From: bob152637485

Misspelled WRITE as WRTIE.