Help with freezing rotation

I am trying to freeze the z axis on my camera but not able to - help?

Because transform.rotation.z is not the rotation of the z-axis, it’s the z component of a Quaternion rotation. It sounds like you want transform.rotation.eulerAngles.z.