camera is tumbling

i am currently digging into javascript and writing some small scripts, but i’m currently having some problems with a camera script. I read out the MouseX and MouseY and use it to change the cameras local rotation

	if (Input.GetMouseButton(2))
	{

	var verticalrotation : float = horizontalSpeed * Input.GetAxis ("Mouse X");
	var horizontalrotation : float = verticalSpeed * Input.GetAxis ("Mouse Y");
	
	transform.Rotate (Vector3.right*horizontalrotation);
	transform.Rotate (Vector3.up*verticalrotation);
	
	}

and

	if (Input.GetMouseButton(2))
	{

	var verticalrotation : float = horizontalSpeed * Input.GetAxis ("Mouse X");
	var horizontalrotation : float = verticalSpeed * Input.GetAxis ("Mouse Y");
	
	transform.Rotate (horizontalrotation,verticalrotation,0);
	}

of course do the same, but when i move my mouse in circles over the table it rotates the camera on its local z axis and creates a tumbling motion around the horizon, but i always want the camera to be upright

you need to distinguish between global/local rotations

To elaborate a bit, cumulative local yaw and pitch (which is what you’re doing) can indeed result in perceived roll. If you want typical ‘FPS-style’ mouse control where the object always remains essentially upright, you’ll need to use a different method (such as tracking the yaw and pitch angles yourself and then building the orientation from scratch each update, e.g. by assigning to transform.eulerAngles).