why wont the enemy die?

im trying to make the enemy die after being hit twice this is the code i have

#pragma strict

var Health = 100;
function Update ()
{
if (Health <=0)
 {
 Dead();
 }
}
 function ApplyDammage (TheDammage : int)
 {
 Health -= TheDammage;
  {
 function Dead ()
   {
 Destroy (gameObject);
   }
  }
 }

thank you for all the help :smiley:

You syntax is off. You have a curly brace facing the wrong way. I think that might be your problem.

#pragma strict

var Health = 100;
function Update (){
    // You don't need to check every frame if the enemy is dead. 
    // You only need to check when the enemy gets hit. 
}

function ApplyDammage (TheDammage : int){
     Health -= TheDammage;
     if (Health <=0){
        Dead();
    }
 }

function Dead (){
    Destroy (gameObject);
}

Probably because you have errors in your code. Your bracketing is mismatched. Make sure you form your code nicer so its easier to read. Add a tab after every open bracket and drop back a tab every time you close one, it makes it wayyy easier to read.

#pragma strict
 
var Health = 100;
function Update () {
    if (Health <=0) {
        Dead();
    }
}

function ApplyDammage (TheDammage : int) {
    Health -= TheDammage;
}

function Dead (){
    Destroy (gameObject);
}

sorry about my bad spelling im dislaktic it makes coding a hell of alot harder ^^" thnx for all the help guys!
i just started learning how to code a short while ago so still have alot of mistakes thnx for helping me improve!