Changing a Game object by looking at it

I have a script I’m working on that is supposed to switch to the character that the player is looking at while pressing “r”. I’m currently using a combonation of Raycast and the Smooth Follow script. I made a GUI text that tells you what you’re looking at, but I really would like to know how to change the target(GameObject) to a different gameObject.

If you instantiated target as a global, then something like var target : GameObejct. --Later throughout the code, when you need to switch the target just pass the new target gameObject. so, target = newTarget as GameObject

I don’t know if I did this correctly. could you point out where I messed up?

@script AddComponentMenu("Camera-Control/CamMo")
//Movement
var target : GameObject;
var speed : float = 2;
var handling : float = 35;

function Start () { 
	speed = target.parent.GetComponent(ShipMov).Topspeed;
	handling = target.parent.GetComponent(ShipMov).Handling;
}
function LateUpdate() {
	transform.position = Vector3.Lerp ( transform.position, target.transform.position,Time.deltaTime * speed);
	transform.rotation = transform.rotation = Quaternion.Lerp(transform.rotation,target.transform.rotation,handling*Time.deltaTime);          
}
//Focus
function Update () {
	var ray =Camera.main.ScreenPointToRay(new Vector3(Screen.width/2,Screen.height/2));
    var hit : RaycastHit;
    	if(Input.GetKey("r")){
    		if (Physics.Raycast (ray, hit, 1000)) {
    			var ThatMov : ShipMov = hit.collider.GetComponent(ShipMov);
				if (ThatMov.enabled != true) {
       				ThatMov.enabled = true;
			}
				var ThisMov : ShipMov = target.parent.GetComponent(ShipMov);
				if (ThisMov.enabled != false) {
					ThisMov.enabled = false;
			}
				newTarget = GameObject.hit.gameObject.child.gameObject;
				target = newTarget;
       	}
	}
}
//Reticule
var reticule : Texture;

function OnGUI () {
	GUI.DrawTexture(Rect(Screen.width/2-15,Screen.height/2-20,30,20),reticule,ScaleMode.ScaleAndCrop,true);
	var ray =Camera.main.ScreenPointToRay(new Vector3(Screen.width/2,Screen.height/2));
    var hit : RaycastHit;
    if (Physics.Raycast (ray, hit, 1000)) {
    	GUI.TextField(Rect(Screen.width/2+200,Screen.height/2+200,80,30),hit.transform.name);
	}
}