making an object stop responding with an object at a certain distance away

i have a turret aiming at my character, how do i get it to stop when my character is at a certain distance?

var LookAtTarget:Transform;

var damp = 6.0;

var laserPrefab:Transform;

var savedTime=0;

function Update () {

if(LookAtTarget)
{
    var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);</p>
    transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);

    var seconds : int = Time.time;
    var oddeven = (seconds % 2);

    if(oddeven)
    {       
        Shoot(seconds);
    }
}

} function Shoot(seconds) { if(seconds!=savedTime) { var laser = Instantiate(laserPrefab ,transform.Find("bang").transform.position, Quaternion.identity); laser.gameObject.tag = "Untagged";

    laser.rigidbody.AddForce(transform.forward * 10000);</p>
    savedTime=seconds;
}

}

thanks :D

Add in the Update function:

if (Vector3.Distance(lookAtTarget.position,transform.position) <= 10){

    // your code here.

}

Two points of advice. First, naming conventions in Unity/Javascript usually begin variables with a lowercase letter and functions with an uppercase one (i.e. lookAtTarget, as opposed to LookAtTarget()...). It will help you keep track of what you are doing (and you'll be surprised at how easy it is to lose track).

Second, you might want to test against the square of the distance you want rather than the distance. Every square root sucks up more computing power, and the end result is the same. Your code would look like:

if ((lookAtTarget.position-transform.position).sqrMagnitude <= 100){ // 100 is 10 squared