Can I use one script to toggle between scenes?

I have this script that I used to toggle the player between one scene and another scene. The script works by calling a function when a certain button is pressed (this function switches the scenes). Take a look:

public class ToggleScript : MonoBehaviour
{
    public Transform normalPlayer;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Q))
        {
            ReloadScene();
        }
    }

    public void ReloadScene()
    {
        SceneManager.LoadScene("AltScene");
        if (Input.GetKeyDown(KeyCode.E))
        {
            LoadOrigional();
        }
    }

    public void LoadOrigional()
    {
        SceneManager.LoadScene("NormalScene");
    }
}

When I run this script, I start in “NormalScene” (as that’s where the game starts). When I press Q, the game takes me to “AltScene” by calling the ReloadScene() function, but when I press E to take me back to “NormalScene” nothing happens. Can someone explain to me why this happens? On a side note, is there any way for me to make sure the player stays in the same positon (so if my player was at X-Coordinate 70 when I switch the scenes I want it to stay at X-Coordinate 70 when the scene is put on again. This issue is not the priority). Thank you so much for your help :slight_smile:

You need to put the

if (Input.GetKeyDown(KeyCode.E))
{
    LoadOriginal();
}

in the update method because once you call the reload scene then it checks for the key E once and then ends the function.

Side Note:
I assume that this script is affected by DontDestroyOnLoad() function so you can get a reference to the player transform at awake and before you call the load functions, store the player’s x in a variable and set the x to that variable’s value with a new Vector3 once you travel to the new scene.