InvalidCastException . trying to assign a variable via a function on a different script.

i have 2 scripts. MissileTrajectory.js and LockOnTest.js
MissileTrajectory is getting a target found by LockOnTest via a function called GetClosest().
The GetClosest function works 100% from within the LockOnTestScript.

there is obviously more script behind it but these are the only parts concerning the error.

MissileTrajectory.js :

private var target : GameObject;
private var lockScript;
function Start () {	
	lockScript = LockOnTest;	
function SetTarget(){
	var tar : GameObject = lockScript.GetClosest();  // error here 
	if(tar == null){
		Debug.Log("target is null");
	target = tar;	

LockOnTest.js :

private	var closest : GameObject;

function GetClosest () : GameObject{
	if(closest !=null){
		return closest;

NeverMind i fixed it. i needed to find my player and get the LockOnTest component from there. networking is a nightmare… but it’s still awesome