NullReferenceException Object reference not set to an instance of an object

i got thios error message in one of my script, and i can’t figure out why it shows that error, anybody who can help?

this is the full error message:
NullReferenceException: Object reference not set to an instance of an object
followPlayer.Update () (at Assets/Scripts/SeaSerpent/followPlayer.js:14)

and here’s the code

var Target : Transform ;

var maxDistance = 1;

var Speed = 7;

var getStart :flyscript3;
getStart = GetComponent(flyscript3);

function Update () 
{
	var dist = Vector3.Distance(Target.position, transform.position);

//line 14 if(getStart.start)
{

	if(dist > maxDistance)
		{
		transform.LookAt(Target);
		transform.Translate(Vector3.forward * Speed * Time.smoothDeltaTime);
		}
		else
		{
			if(dist < maxDistance)
			{
				transform.LookAt(Target);
			}
		}
	}
	else
	{
	
	}
}

Don’t believe you can initialize the getStart value outside of a method. What you should try doing is removing that GetComponent line from the variable declarations and adding it into either the Start() or Awake() method, and see what happens.

You're getting that error because the variable named getStart is null.

You should try to assign that variable in Start() or Awake().

You should also check if it's null (and print an error message) before you try to use it:

function Start ()
{
    getStart = gameObject.GetComponent(flyscript3);
}

/* do nothing if getStart is null */

function Update ()
{
    /* if getStart is null, print error message and bail! */

    if ( ! getStart ) {
        Debug.LogError("getStart is null!");
        return;
    }

    if ( getStart.start ) {
        /* do stuff */
    }
}