How do I make my enemy stop moving towards me within a certain distance?

The enemy I made comes towards me and attacks me - how do I set it so it doesn’t get within a certain distance with me?

var distance;
var target : Transform;
var lookAtDistance = 15.0;
var attackRange = 10.0;
var moveSpeed = 5.0;
var damping = 6.0;
private var isItAttacking = false;

function Update () 
{
distance = Vector3.Distance(target.position, transform.position);

if(distance < lookAtDistance)
{
isItAttacking = false;
lookAt ();
}   
if(distance < attackRange)
{
attack ();
}

}

function lookAt ()
{
var rotation = Quaternion.LookRotation(target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
}

function attack ()
{
isItAttacking = true;

transform.Translate(Vector3.forward * moveSpeed *Time.deltaTime);

}

var standOffDistance : float = 2;

if((distance < attackRange) && (distance > standOffDistance))
{
attack ();
}