Camera Rotation,Camera rotation

I am trying to make a script in javascript to bind a-d to rotate my cameras x and y axis in an specific matter but it does not seem to work. please keep in mind that i am not an experienced programmer.,So i am creating a program in javascript to rotate a camera and my script only causes an error message and i dont know why.

var CameraRotation : float = [transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z];

function Update () {

	if (Input.GetButtonDown("Horizontal") && Input.GetAxisRaw("Horizontal") > 0) {
	CameraRotation[1] - 2;
	CameraRotation[2] - 0.5;

	}

	}

	else if (Input.GetButtonDown("Horizontal") && Input.GetAxisRaw("Horizontal") < 0) {
	CameraRotation[1] + 2;
	CameraRotation[2] - 0.5;

	}
}

Instead of CameraRotation[1] - 2; you should write CameraRotation[1] -= 2;
I’m not exactly sure what happens internally, with the first one, but using the -= operator (or +=) is acutally getting the value, making it lower and then assigning it back.

e.g.

CameraRotation[1] -= 2;

is the same as

CameraRotation[1] = CameraRotation[1] - 2;

And another thing, the indexation of arrays starts at 0 - as in, the first variable is indexed by 0, the second one is indexed by 1 and so on.

So, with CameraRotation[1] you are accessing the transform.eulerAngles.y component of the array and not transform.eulerAngles.x.

To bind a key all you need to do is

if(Input.GetKeyDown(KeyCode.Space)) {
Whatever();
}

thats a snippet not the entire script by the way

gl