How to reset a level after 2 seconds?

I am not sure why, but when I complete the level by triggering a specific “you win” event in another script, the game resets in less than a second instead of 2 seconds. The text pops up correctly, but it doesn’t wait 2 seconds before resetting the game afterwards:

public class GameManager : MonoBehaviour {
    public GameObject youWinText;
    public float resetDelay; 
    
    public static GameManager instance = null;
    private void Awake()
    {
        if (instance == null)
            instance = this;
        else if (instance != null)
            Destroy(gameObject); 
    }

    public void Win()
    {
        youWinText.SetActive(true);
        Wait();
        Invoke("Reset", resetDelay); 
    }

    IEnumerator Wait()
    {
        yield return new WaitForSeconds(2);

    }

 void Reset()
    {
        Application.LoadLevel (Application.loadedLevel); 
    }
}

you were close

        public void Win()
        {
            youWinText.SetActive(true);
            StartCoroutine(Wait()); //need to start the coroutine
            //Invoke("Reset", resetDelay); //dont need this
        }
        IEnumerator Wait()
        {
            yield return new WaitForSeconds(2);
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); // EXZ_EXZ comment
        }

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);


should do the job :slight_smile: