CancelInvoke("Spawn");
int maxEnemy = 50; int enemyCount = 0; void Spawn() { if(enemyCount >= maxEnemy) return; // Instantiate enemyCount++; }