Changing a prefab variable

Hi all,

I am trying to select a unit on mouse down. I am spawning 6 units at the start of the game. These units all share the unitScript. I have stored the units in an array. The spawning function is attached to my main camera. What is supposed to happen is that when one unit is selected, it’s isSelected value is true, and the other units get their values changed to false. I think I am supposed to use GetComponent to do that, but I can’t get it to work. Any suggestions?

//attached to main camera
var player : Transform[];
var numberOfPlayers : int = 6;

function Start () {

for(var x=0; x < numberOfPlayers; x++){
	Instantiate(player[x], Vector3(x * 2.0, 1.38, 3), Quaternion.identity);
	player[x].name = "player" + x;
	}

}

//in the script attached to the units

var isSelected : boolean;

function OnMouseDown () {
		
                //code that will deslect other units here.     
		isSelected = true;
       
       	}

Found solution:

function OnMouseDown () {
		var gos : GameObject[];
		gos = GameObject.FindGameObjectsWithTag("Player");
		for (var go : GameObject in gos){
		go.SendMessage("SetSelected");
		}
		isSelected = true;
       	}

function SetSelected()
{
	isSelected = false;
}