How to move the camera over time?

I’m (obviously) pretty new to Unity. I’m trying to move my camera to a new position. It’s easy enough to have it jump straight to a new location, but I want it move to the new position over time.

I know that I’m looking for the Lerp function. This is the relevant script on my camera:

function Update () {

	var destinationX = pageControl.CurrentPageNumber*pageControl.pageSize;

	var target : Transform;
	target.position = Vector3(destinationX, transform.position.y, transform.position.z);
	
    transform.position = Vector3.Lerp(transform.position, target.position, Time.deltaTime * 5);
    
}

Unfortunately, I just get this error on the target.position line:

NullReferenceException: Object reference not set to an instance of an object 

What am I doing wrong?

You’re telling the compiler that you have a variable called target, and that it’s a Transform. But you don’t set target to anything. So when you try to access its position on the next line (the one with the error) you get the error.
You probably want target to be a vector3 and not a transform.

Put:
var target : Transform;

Outside the Update function:

var target : Transform;

function Update () {

    var destinationX = pageControl.CurrentPageNumber*pageControl.pageSize;

    target.position = Vector3(destinationX, transform.position.y, transform.position.z);

    transform.position = Vector3.Lerp(transform.position, target.position, Time.deltaTime * 5);

}

Then make sure you assign the variable inside the unity editor by dragging the target object into the variable slot under your script component.

Use a coroutine such as MoveObject rather than Update, which isn’t appropriate since it runs every frame and you only want the movement to occur for a set period of time.