What's wrong with my script?

I want my camera to rotate sideways (roll) and rotate up and down (pitch). I don’t know why my script doesn’t work. It lets me do one or the other. But if I roll, then pitch, it does all this wierd stuff and i just don’t understand. Here is my script:

var moveSpeed:float

function Update () 
{
    if(Input.GetButton("up"))
{
    transform.Rotate(transform.right * moveSpeed);
}
if(Input.GetButton("down"))
{
    transform.Rotate(-transform.right * moveSpeed);
}
if(Input.GetButton("left"))
{
    transform.Rotate(transform.forward * moveSpeed);
}
if(Input.GetButton("right"))
{
    transform.Rotate(-transform.forward * moveSpeed);
}
}

The problem is you are using “Left” and “Right” and a bunch of logical but nonetheless nonexistant buttons.

Press Edit–>Project Settings → Input and you can add “Left” and “Right” and so on if you so wish and your problem will be solved as long as you assign the buttons.

On the other hand you can do things the conventional way and use Input.GetAxis. There a four premade axes, which are “Horizontal”, “Vertical”, “Mouse X”, and “Mouse Y”. This will actually simplify your code.

var moveSpeed:float

function Update () 
{
transform.Rotate(transform.right, Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime);
transform.Rotate(transform.forward, Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime);
}