Lock Z rotation to 0

I am rotating a GameObject on the X and the Y axis ONLY, but suddenly the z rotation wants to rotate as well. So i am looking to lock the Z rotation of this object. This GameObject does not have a rigidbody. Heres a piece of my code…

cameraMovementsY = new Vector3 (0, Input.GetAxis (“Mouse X”) * lookSpeed, 0);
cameraMovementsX = new Vector3 (-Input.GetAxis (“Mouse Y”) * lookSpeed, 0, 0);

transform.Rotate (cameraMovementsX * Time.deltaTime);
transform.Rotate (cameraMovementsY * Time.deltaTime);

Thanks for helping!

Rotation by Euler angles can be pretty much unpredictable, if you want to know how it works and what is down side of it look this video Euler (gimbal lock) Explained - YouTube . Like @meat5000 said, it may be that gimbal lock occured.

Try this:

transform.rotation *= Quaternion.Euler(cameraMovementsX , cameraMovementsY, 0f) * Time.deltaTime;

Ive fixed the problem using something else. Thanks for the help guys, i wouldn’t have learned the gimbal thing without you.