NullReferenceException: Object reference not set to an instance of an object follower.Update () (at Assets/follower.js:16)

I do not know how I should write ?I’m new in Java.Help me …

private var waypoint:Transform[];
private var mesafe:float=4;
private var sayac:int=0;
function Start(){

   var i=0;
   for(var child:Transform in spawnPoints){
       waypoint*=child;*

i++;
}
}
function Update(){

mesafe=Vector3.Distance(transform.position,waypoint[sayac].position);
//transform.LookAt(waypoint[sayac].position);
var relavitePos=waypoint[sayac].position-transform.position;
var rotation=Quaternion.LookRotation(relavitePos);
transform.rotation=Quaternion.Slerp(transform.rotation,rotation,Time.deltaTime*10);

transform.Translate(Vector3.forward/2);

if(mesafe<=7){
sayac++;

}
if(sayac>=waypoint.length){

sayac=0;

}
Screen.sleepTimeout = SleepTimeout.NeverSleep;
}

Since you are getting a null reference exception, then most likely some of your way points in your ‘waypoint’ array are null. This appears to be the line indicated with a null reference:

var relavitePos=waypoint[sayac].position-transform.position;

And you are not getting an array out of bounds error, so some entry you are accessing with ‘sayac’ is null.

Note you can rewrite lines 22 - 30 as a single line of code:

sayac = (sayac + 1) % wwaypoint.Length;