I have this code

func save_data():
	var file = File.new()
	file.open("user://save", file.WRITE_READ)
	file.store_var(scene)
	file.close()

func load_data():
	var file = File.new()
	if not file.file_exists("user://save"):
		return false
	file.open("user://save", file.READ)
	scene = file.get_var()
	file.close()
	return true

when i hit continue

func _on_Continue_pressed():
	load_data()
	get_tree().change_scene(scene) 

it gives me this... Resource file not found: res://, why is that?

Does the error display which line the Resource file not found: res:// is on or being triggered by?

My guess would be the change_scene function call on `` is causing the issue. Maybe add print(scene) after line 12 in the first code snippet and see what it shows? Maybe it is not loading it currently. I might also suggest adding print(scene) between lines 2 and 3 in the second code snippet, just to make sure everything is as expected.

Also, what is stored in scene when you save it to a file? The change_scene function takes a string that is the path to the scene file you want to load. If you pass a non-string to it, that could also be contributing to the issue.

(Small note: I fixed code format. You can just post the code with a single tab indent or surround it with three ~ on either side)

@TwistedTwigleg said: Does the error display which line the Resource file not found: res:// is on or being triggered by?

My guess would be the change_scene function call on `` is causing the issue. Maybe add print(scene) after line 12 in the first code snippet and see what it shows? Maybe it is not loading it currently. I might also suggest adding print(scene) between lines 2 and 3 in the second code snippet, just to make sure everything is as expected.

Also, what is stored in scene when you save it to a file? The change_scene function takes a string that is the path to the scene file you want to load. If you pass a non-string to it, that could also be contributing to the issue.

(Small note: I fixed code format. You can just post the code with a single tab indent or surround it with three ~ on either side)

The error is on the continue button at "get_tree().change_scene(scene)", ive been trying to print the scene to see if is all alright but it says null over and over

edit: nvm i got it working, i put "scene = get_tree().current_scene.filename" in the level transition scene and it worked : ) thanks

2 years later