Look for closest gameObject and make another gameObject move there.

I am using a waypoint which is moving to a random waypoint after a specific time. I want to change that so that it moves to the waypoint closest to the player instead and then change as the player is closer to another waypoint, like if it would update each second. Any references would be great since I have not found anything which explains what I need yet.

Best would be to have all waypoints stored in an array so that you avoid looking for them each time.

EDIT: I edited with your scripts info.
Also, make sure your waypoints are populating the array or you have an empty array and nothing returns. Or use GameObject.FindGameObjectsWithTag in the Start

var gos : Transform[] = new Transform[8];
var player : Transform;
var source : Transform;
var speed:float;
 
function Start(){  
   InvokeRepeating("FindClosestWaypoint", 0, 1); 
}
function Update(){
   transform.LookAt(source);
   transform.Translate(0,0,1*Time.deltaTime*speed);
} 
function FindClosestWaypoint () { 
   var distance = Mathf.Infinity;
   var closest:Transform;
   for (var go : Transform in gos) {  
     var curDistance = (go.position - player.position).sqrMagnitude;
 
     if (curDistance < distance) { 
        closest = go;
        distance = curDistance;  
     }  
  }source = closest;

}