Change Camera

I have 2 cameras in a first person controller. When I press the Z button i want it to change from Camera_FPS to Camera_3rd. How would I write a script to do this. Im new to scripting.

Hi,

Look here:

Here you can switch between two cameras:

var cameraMain : Camera; 
var camera3rd : Camera; 
 
function Start () { 
   cameraMain.enabled = true; 
   camera3rd.enabled = false; 
} 
 
function Update () { 
   if (Input.GetKeyDown ("z")){ 
     if ( cameraMain.enabled == true){ 
      camera3rd.enabled = true;
      cameraMain.enabled = false; 
   } 
   else if (camera3rd.enabled == true){
      cameraMain.enabled = true; 
      camera3rd.enabled = false;
       
        
		}
	}
}

This is old, but anyways, here’s a small improvement:

var cameraMain : Camera; 
var camera3rd : Camera; 
      
function Start () { 
    cameraMain.enabled = true; 
    camera3rd.enabled = false; 
} 
      
function Update () { 
    if (Input.GetKeyDown ("z")){ 
        camera3rd.enabled = !camera3rd.enabled;
        cameraMain.enabled = !cameraMain.enabled; 
    }
}