Tap to play again: wait for input

If the Player gives a wrong answer, the scene should be shown until it gets a touch so the actual scene can be reloaded and played again by the player.

void Update()
{
    if (right answer)
    {
    do something
    }
    else
    {
     StartCoroutine(waitForInput());
    }
}

private IEnumerator waitForInput()
{
    while (!Input.GetMouseButtonDown(0))
    {
        Debug.Log("wait for input");
        yield return null;
    }
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}

The problem right here is, that if the player gives an wrong answer the actual scene is reloading without waiting for an input. So basically the while loop is not working and i don’t know why. Does anybody have an idea?

Hey,

Instead of waiting whilst there is no input, how about just triggering the scene when there is an input?

void Update()
{
     if (right answer)
     {
     	//do something
     }
     else
     {
	      Debug.Log("waiting for input");
		  if(Input.GetMouseButtonDown(0))
	     {
	          Debug.Log("Got an input!");
			  SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
	     }
     }
}