Enemy Death and Killing Script

I am working on a side scroller game. you can run around, jump, pick up crates, and stuff like that. What I am having trouble on is making enemies. I want it to be kinda like Braid, or Mario, enemies go back and forth and if you get hit by one you die, but if you jump on it’s head it dies. I have the AI enemy script, but I can’t make it die, or kill you. PLEASE HELP!
I prefer JavaScript, but if you can do it in C# or any other kind that is good too.

Here’s my enemy AI script

var pointB : Vector3;
 
function Start () {
    var pointA = transform.position;
    while (true) {
        yield MoveObject(transform, pointA, pointB, 3.0);
        yield MoveObject(transform, pointB, pointA, 3.0);
    }
}
 
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) {
    var i = 0.0;
    var rate = 1.0/time;
    while (i < 1.0) {
        i += Time.deltaTime * rate;
        thisTransform.position = Vector3.Lerp(startPos, endPos, i);
        yield; 
    }
}


and here is my character respawn script

static var dead = false;

function Update()
{	
	//if you die you respawn in same level
	if(dead)
	{
		Application.LoadLevel(Application.loadedLevel);
	}
	
	//if you fall out of level you respawn
	if(transform.position.y < -25)
	{
		Application.LoadLevel(Application.loadedLevel);
	}
}

function OnCollisionEnter(hit : Collision)
{
	//if you hit the enemy you die
	if(hit.gameObject.tag == ("Enemy"))
	{
		dead = true;
	}
}

All you should need to do is test to see if the player’s Y value is greater than the enemy’s current Y value + the object’s height. If the player’s Y is greater than that value(or nearly so) then the enemy dies because the player is above the enemy. If not, the player dies.

Thanks a lot, but right now even if the player hits the enemy he won’t die

first attach this script to your enemy’s collider and make sure it is called Enemy1.

 var fall :boolean;
  var stomp : boolean;

function Update () {
if(stomp){
transform.position.z = 4;
transform.localScale.y /= 2.00 ;
fall = true;
stomp = true;
}
if (fall){
transform.position.y -= 0.10;
}
if (transform.position.y<-25){
Destroy(gameObject);
}
}

function OnTriggerEnter (other : Collider) {
if (!stomp){
if (other.tag == "Player"){
Destroy(other.gameObject);

}
}
}

Next create a collider that is called stomp and attach it above of your enemy and make sure it is a sub-object of your enemy. Add this script to it.

function OnTriggerEnter (Player : Collider){
transform.root.gameObject.GetComponent(Enemy1).stomp = true;
gameObject.GetComponent(Enemy1).stomp=true;
gameObject.GetComponent(Enemy1).fall=true;

}

that should work