"Pause" for loop?

Hi i have some trouble making a script that choose random arrow (left, right, up, down) and instantiate it in the screen and the player has to click on the same arrow as the screen shows.
so it shows one arrow and you click on it and if he clicked on the right arrow than another arrow printed on the screen.
the problem is, the loop is “skipping” the if statements and continue.
so how do i make it “wait” until a player click on one of thos keys…?
the Script:

var arrows:Transform[];
private var i=0;
private var randomArrow=0;

for (i=0; i<10; i++)
	{
		randomArrow = Random.Range(0,4);
		Instantiate (arrows[randomArrow], Vector3(i * 0.09, 0, 0), Quaternion.identity);
		if(randomArrow == 0)
			{
				if(Input.GetKeyDown("left"))
					{
						Debug.Log("Correct");
						i++;
					}
				if(Input.GetKeyDown("right") || Input.GetKeyDown("up") || Input.GetKeyDown("down"))
					{
						Debug.Log("Incorrect");
						i=10;
					}
			}
		if(randomArrow == 1)
			{
				if(Input.GetKeyDown("right"))
					{
						Debug.Log("Correct");
						i++;
					}
				if(Input.GetKeyDown("left") || Input.GetKeyDown("up") || Input.GetKeyDown("down"))
					{
						Debug.Log("Incorrect");
						i=10;
					}
			}
		if(randomArrow == 2)
			{
				if(Input.GetKeyDown("up"))
					{
						Debug.Log("Correct");
						i++;
					}
				if(Input.GetKeyDown("right") || Input.GetKeyDown("left") || Input.GetKeyDown("down"))
					{
						Debug.Log("Incorrect");
						i=10;
					}
			}
		if(randomArrow == 3)
			{
				if(Input.GetKeyDown("down"))
					{
						Debug.Log("Correct");
						i++;
					}
				if(Input.GetKeyDown("right") || Input.GetKeyDown("up") || Input.GetKeyDown("left"))
					{
						Debug.Log("Incorrect");
						i=10;
					}
			}			
	yield WaitForSeconds(3);
	Debug.Log ("Failed");
	i=10;
	}

Is this running inside Update()?

Why do you have the for loop?

no its not on Update, i need loop cause i want to call it 10 times and after that even more, instead of writing this 10 times, its only once.

I just need that the If’s in the loop will be checked every frame…

That’s exactly what Update is for. Update will be your loop. You can keep a counter to count how many times it has run.
The way you have it, it will just run ten times during the startup (not drawing on screen) and never run again.

Alternately you could use a Coroutine, but I’d start off just doing it in Update.

Also, setting the iterator inside a for loop is generally a bad idea.

you probably want to use ‘break;’ instead.

pakfront is right.

You want a coroutine. In fact, you’re already using one by adding the word “yield” to your code. Because you’re in Javacript, the Unity interpreter figures that all out for you.

What you want to do is the following:

while(!Input.anyKey){ yield return 0; }
if(...)
	Debug.Log("correct");
if(...)
	Debug.Log("incorrect");