Godot Version
4.3
Question
Here’s the situation: When my player dies, the scene changes to “gameover.” When I try to restart the game without changing the scene, pressing restart just brings me back to the gameover screen when I use the reload_current_scene. I have to change the scene again to my main scene. However, the game—specifically my collected keys—does not return to the initial state. Worse, I ended up with 2x of the keys. What is the best approach to solve this?
Are your keys stored in a global/Autoload script? You will have to manually reset those values. Add Global.keys = 0
before reloading or changing the scene.
2 Likes
wait, where do i add this?
Before you change scenes. The line you are looking for might say get_tree().change_scene_to_file("res://main_scene.tscn")
Keep in mind you didn’t paste a script so I have no idea what your global or autoload script is defined as, I was just giving an example with Global.keys
.
1 Like
thank you for the idea! i have solved it.