can't access main camera?

this is my code, trying to work out zooming

#pragma strict

var cam : Camera;
var camDistance : float = 5;
var nowDistance : float = 5;
var maxDistance : float = 5;
var minDistance : float = 2;

var currentX :float = 0;
var currentY : float = 0;
var sensitivity : float = 3;
var dir : Vector3;
var rotation : Quaternion;
var camTransform : Transform;
var lookAt : GameObject;

function Start () {
    camTransform = transform;
    lookAt = GameObject.Find("player");
    cam = Camera.main;
}

function Update(){
    currentX += Input.GetAxis("Mouse Y")*sensitivity;
    currentY += Input.GetAxis("Mouse X")*sensitivity;
    if(Input.GetMouseButtonDown(1)){
        print('2');
        cam.fieldOfView = 2;
    }
}

function LateUpdate () {
    

    dir = new Vector3(0,0,-nowDistance);
    rotation = Quaternion.Euler(currentX,currentY,0);
    camTransform.position = lookAt.transform.position+rotation*dir;
    camTransform.LookAt(lookAt.transform.position+Vector3(1,0.5,0));

}

and I get error message

NullReferenceException: Object reference not set to an instance of an object rotationcam.Update () (at Assets/rotationcam.js:28)

and I am completely lost.

Maybe you just don’t have a camera that qualifies in your scene

The first enabled camera tagged “MainCamera” (Read Only).
Returns null if there is no such camera in the scene.