Racing Game Car - Autovelox

Good evening everyone
I need a script that creates an array of player car speeds, wrotten by passing from waypoints.
This is what I did that not worked, but I need somethink similiar:

var waypointContainer : GameObject;
var waypoints : Array;
var currentWaypoint : float;
var playerCar : Transform;

var speeds : float [];

function Start () {
	GetWaypoints ();
}

function Update () {
	NavigateTowardsWaypoint ();
}

function GetWaypoints () {
	var potentialWaypoints : Array = waypointContainer.GetComponentsInChildren( Transform );
	waypoints = new Array();
	
	for ( var potentialWaypoint : Transform in potentialWaypoints ) {
		if ( potentialWaypoint != waypointContainer.transform ) {
			waypoints[ waypoints.length ] = potentialWaypoint;
		}
	}
	speeds = new float [waypoints.length];
}

function NavigateTowardsWaypoint () {
	var RelativeWaypointPosition : Vector3 = transform.InverseTransformPoint( Vector3( 
												waypoints[currentWaypoint].position.x, 
												transform.position.y, 
												waypoints[currentWaypoint].position.z ) );
												
	if ( RelativeWaypointPosition.magnitude < 25 ) {
		var wp : Waypoint = waypoints[currentWaypoint].GetComponent("Waypoint");
		var speed : float = playerCar.rigidbody.velocity.magnitude;
		speeds[currentWaypoint] = speed; //wp.speed = playerCar.rigidbody.velocity;
		/*var WaypointScript : Waypoint = waypoints[currentWaypoint].GetComponent("Waypoint");
		speeds[currentWaypoint] = WaypointScript.speed = playerCar.rigidbody.velocity;*/
		Debug.Log ("Waypoint: " + currentWaypoint + "; Speed: " + speeds[currentWaypoint]);
		currentWaypoint ++;
		if ( currentWaypoint >= waypoints.length-1 ) {
			currentWaypoint = 0;
		}
		
	}
}

It helps a lot if you tell us what your code is not doing, so that we don’t have to figure out it in our heads.

I have tried this script with the Andrew Gotow Project and it don’t takes any value, but I don’t know if is this the problem!
If is this try with

  1. This is the Actual Script

and this is what i suggest to do:

It has to work, I don’t know, try it!