How to rotate on one axis while keeping the other axes open to be rotated by other scripts?

I’m working on a wallrunning script using the standard rigidbody controller (I have to use this one, I can’t use the Character Controller), and I’m trying to get the camera to rotate ~30 degrees on the Z axis when wallrunning, like a lean effect. However, most methods I’ve tried have constrained the X and Y values of my camera to either 0, or the value they were before wallrunning started. I need to be able to move every axis with other scripts, just have 30 added or subtracted from the Z axis.

One big problem is that the charactercontroller script rotates the camera back every frame, so I can’t just set the rotation at the start of the function, it has to be in the Update loop for the wallrun.

Here’s a list of the things I’ve tried:

transform.Rotate (0, 0, 30);
cam.transform.rotation = Quaternion.AngleAxis (30, cam.transform.forward);
cam.transform.rotation = Quaternion.Euler(new Vector3(0, 0, -30));

Vector3 camEuler = cam.transform.rotation.eulerAngles;
camEuler.z = 30;
cam.transform.rotation = Quaternion.Euler(camEuler);

or this too

cam.transform.rotation = Quaternion.Euler(cam.transform.rotation.eulerAngles.x,cam.transform.rotation.eulerAngles.y,30);