Script instantiates too many objects, causes crash

Following on froma recent question I’m trying to limit how many instantiated objcts can spawn. Simply I wnat one object to respawn, at the set location but it’s instantiating thousands causing a lot of problems for my computer ha!

Where could I be going wrong? Seems okay to me, but I know little SO i ask you guys for help…

var wave2 : boolean;

function Start(){

	var someScript : playerScript;
someScript = gameObject.GetComponent("playerScript");
wave2 = false;

}

function Update(){
amtToMove = enemySpeed * Time.deltaTime;
transform.Translate(Vector3.down * amtToMove);
	if(block.position.y<=20){
	playerScript.playerScore +=5;
	transform.position.y = 31;
	transform.position.x = Random.Range(-7,7);

}
		if(playerScript.playerScore == 0 && wave2 == false){
		var tempBlock : Transform;
		tempBlock = Instantiate(blocked, Vector3(0,32,0), Quaternion.identity);
		wave2 = true;
    }

You have your Instantiate inside an Update function. Move it out to a custom function, and call that function when needed.

I have tried to only use the following code:

var wave2 : boolean;

var playerScore : int;

var prefab : GameObject;

function Start(){

    wave2 = false;

}

function Update()

{

    if(playerScore == 0 && wave2 == false){

       var tempBlock : GameObject;

       tempBlock = Instantiate(prefab, Vector3(0,32,0), Quaternion.identity);

       wave2 = true;

    }

}

which works as intended, is anything accessing the "wave2" boolean from outside? The player script or something else? Thats the only idea I have got right now...