How do you switch between cameras?

So what I’ve been trying to do is make it so that I’m able to switch between cameras so at a press of a button I see a different area. My problem is that I can’t seem to make it so my script works. It currently just stays on enabled camera and doesn’t change (also as a side note, I have the script on my character). I’ve checked google and from what I could tell this script should work.

here is my current script.

var Camera1: Camera;
var Camera2: Camera;

function Start() {
Camera1.enabled = false;
Camera2.enabled = true;
}

if (Input.GetKey(“1”))
{
Camera1.enabled = true;
Camera2.enabled = false;
}

if (Input.GetKey(“2”))
{
Camera1.enabled = false;
Camera2.enabled = true;
}

Thanks!

Drop your key testing code inside a function called Update().