Target question.

I’m trying to make a auto change target script for the MouseOrbit.js script.

I want to change the variable target : Transform;

function CheckActive () {
	if (GameObject.FindGameObjectWithTag("Mothership").active) {
		// Debug.Log("The Mother ship is active.");
		target = GameObject.FindGameObjectWithTag("Mothership").transform;
distance = 10000;
	} else if (GameObject.FindGameObjectWithTag("ColonizationShip").active) {
		target = GameObject.FindGameObjectWithTag("ColonizationShip").transform;
		distance = 3;
	}
}

Ok I did some slight rewriting and this is the result and now it works

function CheckActive1 () {
	Debug.Log("Before Mot. if statement.");
	if (GameObject.FindWithTag("Mothership").active == true) {
		//Debug.Log("Before mother ship.");
		//target = GameObject.FindGameObjectWithTag("Mothership").Transform;
		//Debug.Log("After mother ship.");
		ship = GameObject.FindWithTag("Mothership").transform;
		target = ship;
		distance = 10000;
		}
}

function CheckActive2 () {
	Debug.Log("Before Col. if statement.");
	if (GameObject.FindWithTag("Colonizationship").active == true) {
		//Debug.Log("Before colonization ship.");
		//target = GameObject.Transform;
		//Debug.Log("After colonization ship.");
		ship = GameObject.FindWithTag("Colonizationship").transform;
		target = ship;
		distance = 3;
		}
}