Having trouble with reloading the scene after you die in the project Space Shooter

In the project you are taught how to reload the scene after you die and the way in the video is obsolete, so I did look for the more up to date way to fix the problem, I put in this code:

 void Update ()
    if (restart)
        if(Input.GetKeyDown (KeyCode.R))
            SceneManager.GetActiveScene(); SceneManager.LoadScene("Main");


It doesn’t let me restart. Everything else works, but I am at a loss, I’ve been looking through the manual and scripting api but i still can’t figure it out, please help.

Thank You

Add the scene you want to load to the build settings : File → Build Settings… → Add Open Scenes.

Make sure to add

 using UnityEngine.SceneManagement;

at the beginning of your file.

Also, you should use


if you want to restart the current level.