Spawn script not spawning one at a time?

Every time my object tries to spawn the object I’m trying to spawn it ignores the script telling it to spawn one at a time. Here’s my code (sorry if it’s messy)

var hazard : GameObject;
var node1 : Transform;
var spawnWaitFastMin : float;
var spawnWaitFastMax : float;
var spawnWaitMin : float;
var spawnWaitMax : float;
var spawnWaitMediumMin : float;
var spawnWaitMediumMax : float;
var spawnWaitSlowMin : float;
var spawnWaitSlowMax : float;
var startWait : float;
var CookSpeed : CookMovement;

CookSpeed = GetComponent("CookMovement");
CookSpeed.cookSpeed = 12f;


function Start () {
    SpawnWaves ();
}

function SpawnWaves () {
    yield WaitForSeconds (startWait);
    while (true)
    {
        for ( var i : int= 0; i < (Random.Range(100, 400)); i++)
        {
             Instantiate(hazard,node1.transform.position,node1.transform.rotation);
             	if (CookSpeed.cookSpeed >= 14 && CookSpeed.cookSpeed < 17){
             		   
             		yield WaitForSeconds (Random.Range(spawnWaitSlowMin, spawnWaitSlowMax));
             		}
             		
             	if (CookSpeed.cookSpeed >= 17 && CookSpeed.cookSpeed < 21){
           			 yield WaitForSeconds (Random.Range(spawnWaitMediumMin, spawnWaitMediumMax));
           			}
           			 
                if (CookSpeed.cookSpeed >= 21 && CookSpeed.cookSpeed < 23){
           			 yield WaitForSeconds (Random.Range(spawnWaitMin, spawnWaitMax));
           			}
           			 
           		if (CookSpeed.cookSpeed >= 23){
           			 yield WaitForSeconds (Random.Range(spawnWaitFastMin, spawnWaitFastMax));
                }
                
             }
        
        yield WaitForSeconds (Random.Range(1, 7));
    }
}

basically I’m telling it to keep spawning the object and I call the “cookSpeed” from CookMovement script and get the speed so that as the cook gets faster the object spawns faster, but it started spawning 100+ objects all at once and it appears as one object but is really laggy when it spawns and when i collect it it counts 100 on the score gui. It was working perfectly and I started to tweek stuff to iron out the easiness and hardness and it happened again, so whats wrong here? Thanks in advance.

Check out this post:

YoungDeveloper has an answer that might help you out.