why is my projectile with a destroy enemy script destroy everything it hits?

here is my script (its a javascript by the way) :

var Explosion : GameObject;

var Enemy : GameObject;


function OnCollisionEnter(hit : Collision)

{

	if(hit == "Enemy");
	{
		Destroy(gameObject);
		Destroy(hit.gameObject);
		
		var effect : GameObject;
		effect = Instantiate(Explosion, transform.position, transform.rotation);
	}
	
}

You have two problems here. The thing that is causing your code to destroy everything is the ‘;’ at the end line 10. In addition, the evaluation inside the ‘if’ is wrong. You are comparing a string to a collision. You want either:

if (hit.collider.name == "Enemy")

or

if (hit.collider.tag == "Enemy")

Note no ‘;’ at the end of the line.