Implementing a Lap/Checkpoint System (Racing Game)

Hello There 1st time Poster

Im Currently making a Racing Game and trying to implement a Lap/Checkpoint System where you have to go through for example 4 checkpoints to complete one lap, the vehicle will collide with the checkpoint but then i get this error

NullReferenceException: Object reference not set to an instance of an object
Checkpoints.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Scripts/Checkpoints.js:13)

Here is the Script attached to my Vehicle

#pragma strict

var checkPointArray : Transform[]; //Checkpoint GameObjects stored as an array
static var currentCheckpoint : int = 0; //Current checkpoint
static var currentLap : int = 0; //Current lap
static var startPos : Vector3; //Starting position

function Start () {
	//Store the starting position of the player
	startPos = transform.position;
}

Here is the Script Assigned to all my Checkpoints

static var playerTransform : Transform; //Store the player transform

function Start () {
	playerTransform = gameObject.Find("Player").transform; //Set the player transform
}

function OnTriggerEnter (other : Collider) {
	//Is it the Player who enters the collider?
	if (!other.CompareTag("Player")) 
		return; //If it's not the player dont continue
		
	//Is this transform equal to the transform of checkpointArrays[currentCheckpoint]?
	if (transform == playerTransform.GetComponent(CarCheckpoint).checkPointArray[CarCheckpoint.currentCheckpoint].transform) {
		//Check so we dont exceed our checkpoint quantity
		if (CarCheckpoint.currentCheckpoint + 1<playerTransform.GetComponent(CarCheckpoint).checkPointArray.length) {
			//Add to currentLap if currentCheckpoint is 0
			if(CarCheckpoint.currentCheckpoint == 0)
				CarCheckpoint.currentLap++;
			CarCheckpoint.currentCheckpoint++;
		} else {
			//If we dont have any Checkpoints left, go back to 0
			CarCheckpoint.currentCheckpoint = 0;
		}
		//Update the 3dtext
		GetComponent(GUIText).text = "Checkpoint: "+(CarCheckpoint.currentCheckpoint)+" Lap: "+(CarCheckpoint.currentLap);
	}
}

Any help would be much appreciated after a good 8+ hours of pulling my hair out…

If you are using C# Language. Then here is the C# version of CheckPoint and Laps system.

Laps Script

using UnityEngine;
using System.Collections;

public class Laps : MonoBehaviour {
	
	// These Static Variables are accessed in "checkpoint" Script
	public Transform[] checkPointArray;
	public static Transform[] checkpointA;
	public static int currentCheckpoint = 0; 
	public static int currentLap = 0; 
	public Vector3 startPos;
	public int Lap;
	
	void  Start ()
	{
		startPos = transform.position;
		currentCheckpoint = 0;
		currentLap = 0; 

	}

	void  Update ()
	{
		Lap = currentLap;
		checkpointA = checkPointArray;
	}
	
}

Check Point Script

using UnityEngine;
using System.Collections;

public class checkpoint : MonoBehaviour {
	
	void  Start ()
	{

	}
	
	void  OnTriggerEnter ( Collider other  )
	{
		//Is it the Player who enters the collider?
		if (!other.CompareTag("Player")) 
			return; //If it's not the player dont continue
		

		if (transform == Laps.checkpointA[Laps.currentCheckpoint].transform) 
		{
			//Check so we dont exceed our checkpoint quantity
			if (Laps.currentCheckpoint + 1 < Laps.checkpointA.Length) 
			{
				//Add to currentLap if currentCheckpoint is 0
				if(Laps.currentCheckpoint == 0)
					Laps.currentLap++;
				Laps.currentCheckpoint++;
			} 
			else 
			{
				//If we dont have any Checkpoints left, go back to 0
				Laps.currentCheckpoint = 0;
			}
		}


	}

}

And Just Follow this tutorial to attach scripts on your Game Objects. 1

Sorry Guys in the end i scrapped this feature from my game, but the help was appreciated