Hi! I'm trying to do a game over menu with a simple restart button, but something's not working right. Here's the restart itself:
func on_game_over_menu_actioned(item):
if item == "Retry":
CharacterStats.ready()
get_tree().call_deferred("change_scene_to_file", "res://game.tscn")
Basically rerunning the ready function on my character stats autoload to reset them to defaults, then changing scene to my game manager node which has the first level loaded up inside it. And it works correctly at first, but when I try to walk into the next room, I get the error "change_level(): Node not found: "Level1" (relative to "Level Manager")." which is weird because when I have my Level Manager node print a list of its children, it includes one called Level1 as expected. (It also displays the level correctly.) Here's the part of my room-changing function that seems to be breaking:
func change_level(scene, source, x, y, cam_x, cam_y):
get_node(source).call_deferred("free")
await call_deferred("add_child", scene)
(There's more but it's after the error and just involves resetting some positions on sprites and cameras, so definitely not relevant here.) I'm not sure which of these is causing the problem, or what I can do to fix it?