Timer to call Instantiate

I’ve been coding a game where a player must avoid random enemies as they reach him and have written the code to wait a set amount of time before spawning the next enemy. I have a counter in the Update function that should call the random generator function and reset itself when it reaches a certain threshold, however when I run the program it decides to ignore the if statement and execute everything in the Update function every frame. How can I fix this?

var waitTime: float = 100;
var counter : float = 0;

function Update () {

	//counts up every frame
	counter++;
	print(counter); //temp
	
	//calls enemySpawn when the limit is reached  
	//resets the counter
	if (counter >= waitTime){
		enemySpawn();
		counter = 0;
		}

}

For that kind of things, coroutines are just per-fect. Basically, they allow you to stop the execution of a function for a given amount of time, letting the rest of the program run, and then finishing when the time as past. Here is what you can do :

function Start(){
    Spawn();
}

function Spawn(){
    while( true ){
        enemySpawn();
        yield WaitForSeconds(waitTime); // That line tell the function to stop for waitTime seconds
    }
}