Simple LookAt follow script

I am trying to make a simple following program. It looks like this

var target : GameObject;
var range : float;
var speed : float;
function Update () 
    range = Vector3.Distance(target.transform.position, transform.position);
    if (range<50)
    if (range<40)

It kinda works, but I get this:

UnassignedReferenceException: The variable target of 'ai' has not been assigned. You probably need to assign the target variable of the ai script in the inspector. ai.Update () (at Assets/Enemy/ai.js:6)


It means you didn't assign a gameobject to your varaible "target". You need to assign it in Inspector or assign it at run-time in script.