How to Loop to an array of GameObjects

i have an enemy spawn script
what i want output is that
after instantiating the first object in array it will wait for seconds and move through the next array INDEX.
HELP PLZ? :frowning:

Here is my code:

using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour
{

public GameObject[] enemy;
public Vector3 spawnValues;
public int hazardCount;
public float spawnWait;
public float startWait;
public float waveWait;


void Start ()
{
	StartCoroutine (SpawnWaves ());


}

IEnumerator SpawnWaves ()
{
	yield return new WaitForSeconds (startWait);
	while (true)
	{
		foreach (GameObject objects in enemy)
		{

			Vector3 spawnPosition = new Vector3 (spawnValues.x, Random.Range (-spawnValues.y, spawnValues.y), spawnValues.z);
			Quaternion spawnRotation = Quaternion.identity;
			Instantiate (enemy, spawnPosition, spawnRotation);
			yield return new WaitForSeconds (spawnWait);
			}

		yield return new WaitForSeconds (waveWait);
	}

}

}

Youโ€™re trying to instantiate enemy, which is an array, when you should be instantiating objects. It should look like this:

IEnumerator SpawnWaves ()
{
    yield return new WaitForSeconds (startWait);
    while (true)
    {
        foreach (GameObject objects in enemy)
        {     
            Vector3 spawnPosition = new Vector3 (spawnValues.x, 
                Random.Range(-spawnValues.y, spawnValues.y), spawnValues.z);
            Quaternion spawnRotation = Quaternion.identity;
            Instantiate (objects, spawnPosition, spawnRotation);
            yield return new WaitForSeconds (spawnWait);
        }
        yield return new WaitForSeconds (waveWait);
    }     
}

Foreach loops work in the format:

foreach (var {element} in {collection}) ...

You were just using it the wrong way around.