GameObjects that destroy themselves when there raycast hits the player

i am trying to build a boss ai.
i need it to strafe side to side (which works fine) and move towards the player when he is in range of its raycast but instead it destroys itself as soon as the ray cast hits the player it also instantiates othe enemies that find and move toward the player but they destroy themselves also
it only happens on this level and i cant work out why.
i am new to unity and i have searched around but i cant find any similar questions
here is the boss blocks code

public var moveSpeed : Number = 10.0;
public var moveDirection : Vector3 = Vector3(0,0,1);	//	Initial movement direction
public var errorComp : Number = 0.95;	//	This prevents a body of the same size from missing the object it is touching
var life : int = 60;

var target :Transform;

var speed :int = 20;
var hit : RaycastHit;
var distance : float = 10;
private var Direction : Vector3;
private var ray : Ray;
var mask : LayerMask;


function Move()
{
	var moveDistance : Number = moveSpeed * Time.deltaTime;	//	The distance to move this update
	var hitInfo : RaycastHit;	//	The raycast info variable
 
	//	Check if there is anything in the way
	if (Physics.Raycast(this.transform.position , moveDirection , hitInfo , moveDistance + this.collider.bounds.extents.z))
	{
		//	Reduce the movement distance so the AI doesn't run into the wall
		moveDistance = hitInfo.distance - this.collider.bounds.extents.z;
	}
		//	If there is nowhere to move, turn around
	if ( moveDistance < 0.001 )
	{
		//	turn around
		moveDirection.z = -moveDirection.z;
	}
	transform.position += moveDirection * moveDistance;
}

function Update () {
Move();
if (target != null)
		{
		Direction = target.transform.position - transform.position;
		}else{target = gameObject.FindWithTag("player").transform;}
ray = Ray( this.transform.position , Direction);
if (Physics.Raycast(transform.position, Direction, distance, mask))
{
Debug.DrawRay( ray.origin , ray.direction * distance , Color.green );
transform.position = Vector3(Mathf.MoveTowards(transform.position.x, target.position.x,Time.deltaTime * speed),0,Mathf.MoveTowards(transform.position.z, target.position.z,Time.deltaTime * speed)); 	//	If it hits the player, move towards it
}
else
{
Debug.DrawRay( ray.origin , ray.direction * distance , Color.red );	
transform.position = Vector3(583.6437,this.transform.position.y,this.transform.position.z);
}
}

function damage()
{
life -= 1;
if (life == 0) //only if my life points = 0 will i destroy myself
{
Destroy(gameObject);
}
}
function OnCollisionEnter (other : Collision) 
{
		if (other.gameObject.CompareTag("player")) //send message to the player telling it to destroy itself
		other.gameObject.SendMessage("ApplyDamage");
		Destroy(gameObject);// destroy yourself on impact
}

i dont know what is going on

The last line of the OnCollisionEnter function effectively destroys the boss when the raycast hits it, as you describe. What is the purpose of that line?