I need to make a js function loop.

Hey guys
I am making a random generation script
I don’t know if I am asking the question right but I need to make a JavaScript function repeat itself over and over so here is the script

 	var prefab : GameObject;
	function Start () {
	    yield WaitForSeconds (0);
		var position: Vector3 = Vector3(Random.Range(-5.0, 5.0), 0, Random.Range(-5.0, 5.0));
		Instantiate(prefab, position, Quaternion.identity);
		yield WaitForSeconds (0);
	}

so if someone can help me it will be aprettiated and if someone wants to volunteer and teach my more about JavaScripting contact me please
thanks.

You appear to be on the right track.
Here is a small example to get you started. This will call the MyCoroutine method once which will be running until continueLoop will be set to false. I chose to put 1 second here, change it for your needs. :wink:

#pragma strict

var prefab : GameObject;
var continueLoop : boolean = true; 

function Start () {
	StartCoroutine(MyCoroutine());
}

function MyCoroutine() 
{
	while(continueLoop)
	{
    	yield WaitForSeconds (1);
    	var position: Vector3 = Vector3(Random.Range(-5.0, 5.0), 0, Random.Range(-5.0, 5.0));
    	Instantiate(prefab, position, Quaternion.identity);
    }
}