How to set the z rotation and not simply rotate?

I can’t seem to figure this out, I want my character’s head to tilt as he spins but rather than tilt it keeps turning and goes all “Exorcist”.

Here’s what I’ve got:

var bravelyHead : GameObject;
       /* bunch of cut out code */
		if (play == true){
			if (dead == false){
				bravelyHead.transform.rotate (0,0, spin);
			}
                }

The spin variable is has a max of 3 and a minimal of -3. It never goes past them.

I also tried:

bravelyHead.Transform.Rotation (0,0, spin);

But the moment I apply spin it crashes and I get an error message that says:
“NullReferenceException: Object reference not set to an instance of an object.”

What am I goofing up?

If you’re trying to manipulate the transform’s Euler rotation, it helps to set all three axes. If you’re trying to modify only one axis, it helps to keep the other two.

Something like this:

var euler = bravelyHead.transform.eulerAngles;
euler.z = spin * 10;
bravelyHead.transform.eulerAngles = euler;