problem with array index out of range

hi guys i trying to make my player object to collide with the cube object which by right will print out laps 1 on the race track .but there an error which said "array index is out of range"and i can’t figure out why can anyone help me?

here is the script for cube object:

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(player).checkPointArray[player.currentCheckpoint].transform) {
		//Check so we dont exceed our checkpoint quantity
		if (player.currentCheckpoint+1<playerTransform.GetComponent(player).checkPointArray.length) {
			//Add to currentLap if currentCheckpoint is 0
			if(player.currentCheckpoint==0)
				player.currentLap++;
			player.currentCheckpoint++;
		} else {
			//If we dont have any Checkpoints left, go back to 0
			player.currentCheckpoint=0;
		}
		visualAid(); //Run a coroutine to update the visual aid of our Checkpoints
		//Update the 3dtext
		Camera.main.GetComponentInChildren(TextMesh).text = "Checkpoint: "+(player.currentCheckpoint)+" Lap: "+(player.currentLap);
	}
}

I could not find any error in your script, since it already checks the array length before incrementing currentCheckpoint. I only found somewhat weird the use of GetComponent to access checkPointArray - since currentCheckpoint is a static var, I suppose checkPointArray is static too. Is it true? I would make checkPointArray static, then access it using player.checkPointArray, like below:

    if (transform == player.checkPointArray[player.currentCheckpoint].transform) {
        //Check so we dont exceed our checkpoint quantity
        if (player.currentCheckpoint+1<player.checkPointArray.length) {
            ...

I already had some trouble with complicated constructions using GetComponent, so I try to simplify them whenever possible.

Another possible cause for this error is some other script altering currentCheckpoint.