Rotation Constraint doesn't work properly

I am trying to use rotate constraint with the following script but nothing seems o happen. Can anyone tell me the easiest way to limit the rotation of a camera attached to object so it won’t go through the floor.

Here is my current script I thought was closest to my goal from another post. but it doesn’t respond to inspector limits.

var target : Transform;
var distance = 10.0;
var xSpeed = 250.0;
var ySpeed = 120.0;
var yMinLimit = -20;
var yMaxLimit = 80;
var xsign =1;

private var x = 0.0;
private var y = 0.0;

@script AddComponentMenu("Camera-Control/Mouse Orbit")
function Start()
{
    var angles = transform.eulerAngles;
    x = angles.y;
    y = angles.x;

    var rotation = Quaternion.Euler(y, x, 0);
    // /!\ This is the equivalent of transform.forward * -distance + target.position
    // You're sure that's what you want ?
    // By the way, those for lines are identical to those in LateUpdate, you should
    // never have twice the same thing when you code, use a function instead.
    var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
    transform.rotation = rotation;
    transform.position = position;
}

function LateUpdate()
{
    //get the rotationsigns
    // /!\ Those are transform.up and target.up.
    var forward = transform.TransformDirection(Vector3.up);
    var forward2 = target.transform.TransformDirection(Vector3.up);

    if (Vector3.Dot(forward,forward2) < 0)
        xsign = -1;
    else
        xsign =1;

    for (var touch : Touch in Input.touches) 
    {
        if (touch.phase == TouchPhase.Moved) 
        {
            x += xsign * touch.deltaPosition.x * xSpeed *0.02;
            y -= touch.deltaPosition.y * ySpeed *0.02;

            var rotation = Quaternion.Euler(y, x, 0);
            var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
            transform.rotation = rotation;
            transform.position = position;
        }
    }
}

I’ve left some remarks in your code, check the // /!\ comments.

For your probleme, you need to clamp x and y before creating the Quaternion with Euler().