Collision destroyed script on player collision

I’m making a game where an object moves towards you, but when it gets close enough, the objects moving script get’s destroyed. How would a script like that be made? Here is the follow script:

var speed : int = 0;
var followrange : int;
var stoprange : int;
static var canmove : boolean = true;
var target : Transform;
private var stopped : boolean = false;

function Update(){

if(Vector3.Distance(target.position, transform.position) <= followrange && stopped == false)
{
canmove = false;
transform.LookAt(target);
transform.Translate(Vector3(0,0,1) * speed * Time.deltaTime);
}

if(Vector3.Distance(target.position, transform.position) <= stoprange)
{
canmove = false;
transform.LookAt(target);
stopped = true;
}

if(Vector3.Distance(target.position, transform.position) > stoprange)
{
stopped = false;
}

if(Vector3.Distance(target.position, transform.position) > followrange)
{
canmove = true;
}

}

If you want to destroy the script, you can put

Destroy(this);

where you want the script to be completely removed.