How to fix this scene problem.

I was following this tutorial Using a Unity button to switch between scenes. and when I try to make this script in another scene it doesn’t work. I am using this as a reset button for my game to restart the level because I couldn’t figure out how to make a key like r do it instead. Is there a way I can use r instead of this method?

This is for the button method.

using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneSwitcher : MonoBehaviour
{
    private const string SceneName = "LevelOne";

    public void GotoMainScene()
    {
        SceneManager.LoadScene("LevelOne");
    }

    public void GotoMenuScene()
    {
        SceneManager.LoadScene(SceneName);
    }
}

Hello @itsdandd ,
Have a look at the Input.GetKeyDown() method here in the manual, and its example:

Hopefully this can help you achieve your goal.
Let me know how it goes!

Would this work for multiple scenes? The manual didn’t help that much.

Thank you for replying!

Never mind I found this and it works. Thank you for your time!

void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            SceneManager.LoadScene("Main menu");
        }
    }