Using Yield Wait for seconds with instantiate

I’m trying to create a simple runner and have the game spawn a new enemy every 3 seconds, but when I use yield within a function instead of spawning a new enemy every 3 seconds, after 3 seconds the game doesn’t stop spawning enemies. I’m betting it’s something simpel but I’m not seeing it.

public var Spawn : GameObject;

function Update () {
    CreateEnemy();
}

function CreateEnemy () {
	var enemyInstance: GameObject;
	yield WaitForSeconds(3.0);
	enemyInstance = Instantiate(Spawn,transform.position,transform.rotation);
}

This is because the Update function is calling ‘CreateEnemy’ as fast as it can continuously. Try this -

function Start()
{
	InvokeRepeating("CreateEnemy", 0, 3);
}

function CreateEnemy()
{
	var enemyInstance : GameObject;
	enemyInstance = Instantiate(Spawn,transform.position,transform.rotation);
}

Relevant docs - Unity - Scripting API: MonoBehaviour.InvokeRepeating