Can't rotate on y axis

I am using this code to orient the player to the slope of whatever is below it:

function Update () {
    var hit : RaycastHit;
    var castPos = Vector3(transform.position.x,transform.position.y-.25,transform.position.z);

    if (Physics.Raycast (castPos, -transform.up, hit)) {
        transform.rotation = Quaternion.FromToRotation (Vector3.up, hit.normal);
        transform.rotation.z = 0;
    }
}

This makes the player rotate to the ground. The thing is, it completely restricts their y rotation and you can only move forward/backwards (It is allows extremely trippy and jumps in wierd rotations at times). How do I release the y axis? I only really need the x to rotate up or down, with the z frozen.
Please, HELP… Thanks in Advance

I may be missing it here, but you know in Unity the Y axis is up and down, right? like if you want to turn left or right you turn on the y axis.

EDIT: Damn, should have read more closely. Have you tried Quaternion.AroundAxis(Angle in degrees, vector3.right)?

–Eric

Hm? AroundAxis doesn’t highlight in the scripts text- is it a var I have to set? Never heard of it.

Mmm…yes I do…but I what I don’t understand is how to get this work without restricting it. I am kind of newb with script. I really only understand basic logic as opposed to the precise technicalities behind the words. If you could you explain any obvious(?) things youre noticing I would appreciate it