Limiting Rotation

Well i'm making a spaceship racing game and i'm having some problems. I want to limit the rotation of the space ship so the player can't go to the inverse direction of the track. This is the script:

function Update(){

var horizRotate = Input.GetAxis("Horizontal") * velocidadeDeRotacao * Time.deltaTime;


Mathf.Clamp(transform.rotation.y, minY, maxY);


basically i want to limit the y rotation to around 45 and -45 degrees. i'm using Mathf.Clamp, but it doesn't worked for me. Is there an other way to do this? Thank you.

If it were me, i'd just store the wanted rotation as a variable, and create the rotation each frame with clamped values:

var horizRotate : float = 0.0;

function Update()
    horizRotate += Input.GetAxis("Horizontal") * velocidadeDeRotacao * Time.deltaTime;
    horizRotate = Mathf.Clamp(horizRotate, -45, 45);
    transform.rotation = Quaternion.Euler(0, horizRotate, 0);

Small edit:

Don't modify transform.rotation.x/y/z/w - Those are quaternion values, not euler, so they're not in degrees, and the maths relating to them are kinda crazy