When the ClickAttack() function is called below, the Unity game crashes. I am not sure why.

There are three objects in the area, two with this script. The ClickAttack() function is first called on one of these objects. Nothing is supposed to happen when the object hits a factory. Additionally, the objects have a network transform attached to them.

   private void possibleTarget ()  
    {

	Vector3 thisPos = this.transform.position;
	GameObject a = Instantiate (AttackSignal);
	a.transform.position = new Vector3 (thisPos.x, thisPos.y + 10, thisPos.z);
	//Temporary
	gameObject.GetComponent<Renderer> ().material.color = Color.green;
	InAttackMode = true;
}

void ClickAttack(Vector3 center, float radius)
{
	Collider[] hitColliders = Physics.OverlapSphere(center, radius);
	int i = 0;
	while (i < hitColliders.Length)
	{
		if (hitColliders *.tag == "Vehicle") {*

_ hitColliders .GetComponent ().possibleTarget ();_
_ } else if (hitColliders*.tag == “Factory”) {
hitColliders .GetComponent ();
}
}
}
public void OnCollisionEnter(Collision col) {
//If the object is tagged as a weapon, then it subtracts its Attack Damage from its Health.
if (col.gameObject.tag == “Weapon”) {
//Checks if object has vehicle script*

* var script = col.gameObject.GetComponent();
if (script != null) {
Health -= col.gameObject.GetComponent ().ADamage;
} else {
Debug.Log (“No Vehicle Script attached to " + col+”.");
}
if (Health < 0) {
Destroy (this.gameObject);
}
//Instantiate (bullet, col.gameObject.transform.position);
}
}
public void Attack(GameObject target) {
gameObject.transform.LookAt (target.transform.position);
Fire ();
target.GetComponent ().AttackBack (this.gameObject);
}
public void AttackBack(GameObject target) {
//target.GetComponent().Health*

* gameObject.transform.LookAt (target.transform.position);
Fire ();
InAttackMode = false;
}
public void Fire() {
Instantiate (bullet);
}
public GameObject getVehicle() {
return gameObject;
}*_

The issue is that you are not incrementing i in your while loop. The condition while (i < hitColliders.Length) is always true because i is always equal to 0 creating an infinite loop. Add ++i to the end of the loop and it should fix things.