How to make camera never orientate based on Z axis

Title is exactly as it says. I have an issue. I am controlling my camera utilizing a custom script. I do this by rotating the camera with the mouses first person delta.

But It rolls on the X and Y axis perfectly, as it should, but unexpectedly it rolls on the Z. how do I eliminate the evil Z axis??

1 Like

What script do you currently have?

You can have a script that constantly sets the Z axis to a fix rotation, and I think you are able to unbind it via ContextActionService

It’s a bit confusing because its countering alot of stuff like rotation based on a lock part
but here it is:

		cam.CFrame = (CFrame.new(0,0,0)*variables.CFOffset)*CFrame.Angles(0,math.rad(camangle.X),0)
		cam.CFrame = cam.CFrame*CFrame.Angles(math.rad(camangle.Y),0,0)
		
		cam.CFrame = cam.CFrame+campart.Position
		
		local x,y,z = cam.CFrame:ToEulerAnglesXYZ()
		cam.CFrame = CFrame.new(cam.CFrame.Position)*CFrame.Angles(x,y,0)

I tried to fix the Z problem in the last 2 lines but it didnt work
Long story short I just need to take a cameras cframe and delete the Z rotation from it