WaitForSeconds not functioning?

Hi all!
I am trying to spawn a GameObject every five seconds. I use WaitForSeconds to do this. However, my GameObject is spawned every frame instead. Where is the flaw in my code? Thanks!


You can try that

bool canInstantiate = true

void Start()
enemy = ...;
if (canInstantiate)

IEnumerator EnemySpawn()
canInstantiate = false;
yield return new WaitForSeconds(5f);
canInstantiate = true;