Godot Version
4.6.1
Question
Hello everyone! I am new to Godot and Programming and after failing and realizing I can’t make the game I wanted and looked online advice and stuff, I started by doing small game project and so on.
right now I am on my first game, a 2d platformer, it been around a week and it been pretty much a learning experience, but since a few a days ago I have been stuck on a problem I can’t seem to find a solution after tackling it down and failing a couple of time,
my problem is that right now I am trying to make a 2nd level, which made me realize that I need to make my TileMapLayers into scene and add them when needed which wasn’t the hard part I even added a new game menu that launch the first level just fine, and I did for the 2nd do(doesn’t work any longer). but it wasn’t meant to be, because my try again button that I am using to restart the game, literally restart the game but it need to restart the “level”, one of my attempt was to level_1.queue_free() ← direct path to my level 1 scene and re-add it again as a child node to my Main/Game node but it doesn’t work, I tried added arguments to my button function since my Main Script is Autoload so that I could use them later on, on my level_1 script to make my main script lighter and easier to read, I was able to make the next level button work… except it started my game on level 2 despite never pressing it.
for now I am giving up trying to use a global script for other level script to make it work I am just trying to make it work basic, so I tried:
get_node(“/root/Game/Level1”).queue_free()
get_tree().paused = false
await get_tree().create_timer(0.1).timeout
get_tree().current_scene.add_child(level_1)
Edit: I only added the “await” here because it tried to add the level_1 first before freeing it, which confuse me since from my understanding GDScript read from top to bottom so it should have deleted the level node first but I keep getting error that it can’t since level_1 is already a child of Game(my main node) which force me to add this but it still doesn’t work and create a weird time lag.
it crash the game without error now, I check online and so on for day trying to find a solution on how to make it work but all the “level” method feel like won’t work on button, unless I am dumb and don’t know how to make it work for me, which I don’t doubt is kinda true.
so now I am asking for guidance, I am thinking maybe creating a new function to free the level_1 node and add it to my button when I press it and adding the level as a child again, or I am doing a wrong approach about it?

