Limit rotation

how do i limit the rotation in this script to wanted angles?

    var rotateSpeed = 3.0;
	
    function Update ()
	
	
     	 {
           var controller : CharacterController = GetComponent(CharacterController);
            transform.Rotate(Input.GetAxis ("Vertical1") * rotateSpeed, 0, 0);
			
			}

help much appreciated /Johan

It should be something like what I have below. You will want to pull the x rotation from the local angles. Then constrain it to your max angels. Then reapply it to the local angle.

var rotateSpeed = 3.0;
var angleLock=45.0;
var rotation=transform.localEulerAngles;
var x=rotation.x;
if(x>180.0)x=x-360.0;
if(x> angleLock)x=angleLock;
if(x<-angleLock)x=-angleLock;
x=x + Input.GetAxis ("Vertical1") * rotateSpeed * Time.deltaTime;
rotation.x=x;
transform.localEulerAngles=rotation;

Thank you BigMisterB ill try it out later tonight!