disable component on identical objects in array.

I have an array of 10 objects with the same script attatached to each, I want to disable/enable them all one by one but I can’t seem to find the solution to do it correctly? what I have:

public GameObject[] enemies;

void Update(){
		enemies = GameObject.FindGameObjectsWithTag("Enemy");

}

// Somewhere else called from anohter script:

	public void CastScore(string comboAdd){
foreach(GameObject Enemy in enemies){
		enemies.GetComponents<Enemy>().enabled = false;
}

//other code non related

}

I thought it would be as simple as that but it’s not really working and the things I’ve tried aren’t either.

Thanks.

public void CastScore(string comboAdd){
foreach(GameObject enemy in enemies){
enemy.GetComponent().enabled = false;
}
}

Here is the name of your Component that you want to disable from your enemy game object.

Also do not put your

enemies = GameObject.FindGameObjectsWithTag("Enemy");

inside Update() since it is a heavy process. If you require to do it once at beginning then perform it in Start() otherwise you can trigger this action only when required.