Display a GameOver scene then restart the game

Hello,
I’m trying to display the gameOver scene I made and after some time, like 5s, restart the game by loading the game scene.

I made this, but it doesn’t restart the game and stays on the gameOver scene.

using UnityEngine;
using UnityEngine.SceneManagement; // Quand on à besoin de faire appel à une autre scene
public class GameManager : MonoBehaviour {

	bool gameEnd = false;

    public float restartDelay = 3f; 

    public void EndGame()
    {
        if (gameEnd == false)
        {
            gameEnd = true;
            Debug.Log("Game OVER");
            Invoke("Restart", restartDelay); // Invoke sert à appeller la fonction à partir d'un certain temps
			SceneManager.LoadScene("Terrain", LoadSceneMode.Additive);
			SceneManager.LoadScene("FinLoose");

		
        }
    }

        void Restart ()
        {
		SceneManager.SetActiveScene (SceneManager.GetSceneByName("Terrain"));
        }    
    }

I need to change to MonoBehaviour then ?
I want to load the scene “Terrain” after 3 or 5 seconds, but still show the GameOver scene.

your are calling SceneManager.LoadScene("FinLoose"); so i guess this object die when changing the scene.

Just try not calling SceneManager.LoadScene("FinLoose"); and see what happens. If the restart scene appears then i what i told you.


If it is what i told you you need to add the restart code in the FinLoose scene

When I do not call this scene, the games restarts just like before, but I don’t get to see the scene with the score.