Are these scripts causing Unity to freeze up?

I’m trying to test out a script for a tower defense game we’re working on to create enemy waves, combined a script used to spawn enemies by cloning one on “standby”, but after attaching the Spawner script to the enemy & putting the Waves script in play, Unity just freezes up whenever I try to run things & test it out. Is there something wrong? I knwo things aren’t perfected at the moment, but I just want to see if the initial aspects work.

Here’s the code to spawn enemies:

using UnityEngine;
using System.Collections;
//Attach to one enemy in hierachey, another in assets, summon when needed
public class Spawner : MonoBehaviour {
	
	public GameObject Enemy;
	public bool Flood = false;
	void Start () {
		SpawnIt ();
	}
	
	public void Update(){
		if(Flood){
			SpawnIt();	
		}
	}
	
	public void SpawnIt () {
		GameObject[] foundSpawn = GameObject.FindGameObjectsWithTag("SpawnPoint");
		GameObject Drone;
		Drone = Instantiate(Enemy, foundSpawn[0].transform.position, foundSpawn[0].transform.rotation) as GameObject;
	}
}

…And here’s the code to create enemy waves (so far):

using UnityEngine;
using System.Collections;

public class Waves : MonoBehaviour {
	
	int waveCounter = 3;
	public void Start () {
		while (waveCounter > 0) {
			GameObject[] foes = GameObject.FindGameObjectsWithTag("Enemy");
			int foesNum = foes.Length;
			if (foesNum == 0) {
			
				Spawn ();
				waveCounter--;
				
			}
			else Debug.Log("You win!");
		}
	}
	
	public IEnumerator Spawn(){
		
		yield return new WaitForSeconds(5);
		GameObject go = GameObject.Find("A*");
		for(int x = 0; x < 3; x++) {
    		go.GetComponent<Spawner>().SpawnIt();
		}
	}
}

…Any ideas as to what’s causing things to freeze?

There is a pathway here that in theory will hang Unity. In your second script on line 8 you start a ‘while’ loop. It will only exit if ‘waveCounter’ equals 0. You decrement ‘waveCounter’ inside the a ‘if (foesNum == 0)’ clause starting on line 11. So if your 'FindGameObjectsWithTage() succeeds in finding anything, then you will never enter the ‘foesNum == 0’ clause, so ‘waveCounter’ is never decremented, so this code spins in this loop forever. This all assumes that findGameObjectWithTag() is finding a foe.