# Enemy health (648912)

**URL:** https://discussions.unity.com/t/enemy-health-648912/648912
**Category:** Scripting
**Tags:** Scripting
**Created:** [December 13, 2016, 6:16pm UTC](https://discussions.unity.com/t/enemy-health-648912/648912 "2016-12-13T18:16:49Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![onefishykid](https://avatars.discourse-cdn.com/v4/letter/o/ea666f/32.png) [@onefishykid](https://discussions.unity.com/u/onefishykid)
#### Post date: [December 13, 2016, 6:16pm UTC](https://discussions.unity.com/t/enemy-health-648912/648912/1 "2016-12-13T18:16:49Z")

</div>

I need help with my java i have used this script to destroy the enemy when health is = to or under 0

#pragma strict

var Health = 100;

function Update ()  
{  
if(Health \>= 0);  
{  
Destroy(gameObject);  
}  
}  
function ApplyDammage (TheDammage : int)  
{  
Health -= TheDammage;  
}

the destroy game object is running instantly and killing of the enemy before the health has bean reduced basically. dose anyone know how to solve it if so you can either email me at [onefishykid2015@gmail.com](mailto:onefishykid2015@gmail.com) or post back on these forums it will be greatly appreciated thank you.  
there is another script By the way that inflicts the damage and it dose reduce health from 100 to 50 to 0. i tested without the destroy game object in and it worked

---

<div class="post-metadata">

### Author: ![\_met44](https://avatars.discourse-cdn.com/v4/letter/_/3bc359/32.png) [@\_met44](https://discussions.unity.com/u/_met44)
#### Post date: [December 13, 2016, 6:20pm UTC](https://discussions.unity.com/t/enemy-health-648912/648912/2 "2016-12-13T18:20:15Z")

</div>

Ask yourself, what does " \>= " stands for ?

---

<div class="post-metadata">

### Author: ![GroZZleR](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/grozzler/32/316385_2.png) [@GroZZleR](https://discussions.unity.com/u/GroZZleR)
#### Post date: [December 13, 2016, 6:21pm UTC](https://discussions.unity.com/t/enemy-health-648912/648912/3 "2016-12-13T18:21:26Z")

</div>

> = is greater than, you want \<=

---

<div class="post-metadata">

### Author: ![onefishykid](https://avatars.discourse-cdn.com/v4/letter/o/ea666f/32.png) [@onefishykid](https://discussions.unity.com/u/onefishykid)
#### Post date: [December 16, 2016, 2:48pm UTC](https://discussions.unity.com/t/enemy-health-648912/648912/4 "2016-12-16T14:48:26Z")

</div>

i tried it the outher way around and still dose the same

---

<div class="post-metadata">

### Author: ![TaleOf4Gamers1](https://avatars.discourse-cdn.com/v4/letter/t/c77e96/32.png) [@TaleOf4Gamers1](https://discussions.unity.com/u/TaleOf4Gamers1)
#### Post date: [December 16, 2016, 3:27pm UTC](https://discussions.unity.com/t/enemy-health-648912/648912/5 "2016-12-16T15:27:04Z")

</div>

> [@onefishykid](#):
>
> i tried it the outher way around and still dose the same

Then there is another underlying problem.  
When is ApplyDamage being called. OnCollisionEnter? OnTriggerEnter?  
Please for the love of god learn how to debug. Add a Debug.Log() to the ApplyDamage method so you can actually track when things take damage and for how much.
