This is hard to explain but I am making a 2d platformer. There are 2 levels and I have a basic global variable that contains the player spawnpoint. This worked for the first level, where each time you reached a checkpoint (an area2d) your spawnpoint is updated, and then when you die I reload the scene. But now that I have a second level I created a second spawnpoint variable to store the level2 spawn.
I then made it so when you load into level 1 or 2 it stores what level you are on in a global variable called current_variable. Then in the playerscript in func_ready() there is an if statement that checks the current level and depending on if 1 or 2 it sets self.position = the respective spawnpoint variable.
The death and reloading works fine but when exiting the level and re-entering it seems to get confused. I cant figure out why, using prints I figured out that the game is succesfully noticing what level you are on and the if statement is working. But it doesn't always set you to the right position, but I am pretty sure that the global variables are not being messed with. My greatest suspect is some functionality of the scene loading that I don't understand since I am new to Godot.