Change LookAt camera target on Waypoints

I am trying to move a camera along a path but change the target of the camera now and then, for example when I am at a particular waypoint; but i cannot figure out how to get that waypoint in script. I am using this to move the camera with success so far.

private var currentWaypoint : Transform;
private var currentIndex : int;
var moveSpeed : float = 10.0;
var minDistance : float = 2.0;

function Start ():void

{

   currentWaypoint = waypoints[0];
   currentIndex = 0;

}
function Update ()

{

   MoveTowardWaypoint();

   if(Vector3.Distance(currentWaypoint.transform.position, transform.position) < minDistance)

   {

      ++currentIndex;

      if(currentIndex > waypoints.Length -1)

      {

         currentIndex = 0;

      }

      currentWaypoint = waypoints[currentIndex];

	}
	
}

function MoveTowardWaypoint() : void


{
   var direction : Vector3 = currentWaypoint.transform.position- transform.position;
   var moveVector : Vector3 = direction.normalized * moveSpeed * Time.deltaTime;
   transform.position += moveVector;
   transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(direction), 4 * Time.deltaTime);


}

I’m thinking you should probably just do something like this:

public Transform[] waypoints;
public float moveSpeed = 10.0f;
public float minDistance = 2.0f;

private Vector3 currentWaypoint;
private int currentIndex;

void Start ()
{
	currentWaypoint = waypoints[0].position;
	currentIndex = 0;
}

void Update ()
{
	MoveTowardWaypoint();
	if((currentWaypoint - transform.position).sqrMagnitude < minDistance * minDistance)
		ArrivedAtWaypoint();
}

void ArrivedAtWaypoint()
{
        currentIndex = ++currentIndex % waypoints.Length;
        currentWaypoint = waypoints[currentIndex].position;
}

void MoveTowardWaypoint()
{
	transform.position = Vector3.MoveTowards(transform.position, currentWaypoint, moveSpeed * Time.deltaTime);
	transform.LookAt(currentWaypoint);
}