Using JSON.sav file to load a saved scene from the main menu

Hello!
I am currently using the GODOT save and load system using JSON,
Saving games — Godot Engine (stable) documentation in English, I am currently saving my "current scene on my player like this:

"currentscene" = get_tree().current_scene.scene_file_path,

My issues comes within the loading file as the saving works fine, here is the code I am using to load a scene

var node_data = json.data
		if node_data.has("currentscene"):
			newscene = load(node_data["currentscene"])
			
		await get_tree().process_frame
		var new_object = load(node_data["filename"]).instantiate()
	
	
		get_node(node_data["parent"]).add_child(new_object)

however when I attempt to load form the main menu it gives me this error, and I dont know how to fix it or how to properally load a save game from the main menu or from another scene


If anyone can help it would be greatly appreciated!

All this error tells you is that this piece of code: get_node(node_data["parent"]) is null at runtime.

You need to show us the full save and load functions to properly help you solve this problem.

save - Pastebin.com Does this work?

Can you show your nodes’ save function? How do they assign “parent”?


You can paste directly into the forum, preferabley between three ticks ```

This is in my player script

func save():
	var scene = get_parent()
	
	var playerdictionary = {
			"filename" = get_scene_file_path(),
			"currentscene" = get_tree().current_scene.scene_file_path,
			"parent" = get_parent().get_path(),
			"pos_x" = self.position.x,
			"pos_z" = self.position.z,
			"pos_y" = 1.758,
			"camera" = playercamera,
			"body" = head,
			"name" = charactername,
			"rotation_x0" = self.global_transform.basis.x[0],
			"rotation_x1" = self.global_transform.basis.x[1],
			"rotation_x2" = self.global_transform.basis.x[2],
			"rotation_z0" = self.global_transform.basis.z[0],
			"rotation_z1" = self.global_transform.basis.z[1],
			"rotation_z2" = self.global_transform.basis.z[2]
			
			}
			
	return playerdictionary
			}

Are you sure the parent path exists when this load function is called? Is the parent a dynamically created object too?

Sorry I am very new to coding (I’ve been only doing it for two months), this is what it shows when I press the load button, I dont know if that helps

In my main menu (where it doesnt work):


In my game (Where it does work)

I really appreciate the help! If there is anything else that you need let me know,
My issue is I dont know how to get rid of the Main Menu and add the Protoype scene, and thena dd the updated children