# How do you give each enemies their own health

**URL:** <https://forum.makecode.com/t/how-do-you-give-each-enemies-their-own-health/11266>\
**Category:** Help\
**Created:** [December 8, 2021, 5:45pm UTC](https://forum.makecode.com/t/how-do-you-give-each-enemies-their-own-health/11266 "2021-12-08T17:45:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LcAtonal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/lcatonal/32/16800_2.png) [@LcAtonal](https://forum.makecode.com/u/LcAtonal)\
**Post date:** [December 8, 2021, 5:45pm UTC](https://forum.makecode.com/t/how-do-you-give-each-enemies-their-own-health/11266/1 "2021-12-08T17:45:36Z")

</div>

> **[Tower Defence Game (Beta v0.1)](https://arcade.makecode.com/14246-33995-73119-37820)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I am not sure how to give each enemy health. For instance, the enemy in the game, I want it to have 4 hp, but after the projectile hits the enemies 4 times, all the enemies will have 0 hp.  
I dont want the health of the enemies to decrease when only 1 enemy is shot.

---

<div class="post-metadata">

**Author:** ![Grimm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/grimm/32/5507_2.png) [@Grimm](https://forum.makecode.com/u/Grimm)\
**Post date:** [December 8, 2021, 6:41pm UTC](https://forum.makecode.com/t/how-do-you-give-each-enemies-their-own-health/11266/2 "2021-12-08T18:41:39Z")

</div>

Well you can use things like player 2 health-player 4 health

---

<div class="post-metadata">

**Author:** ![drtongue96](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@drtongue96](https://forum.makecode.com/u/drtongue96)\
**Post date:** [December 8, 2021, 6:41pm UTC](https://forum.makecode.com/t/how-do-you-give-each-enemies-their-own-health/11266/3 "2021-12-08T18:41:56Z")

</div>

use the data extension, and give them health when you create each sprite. in your +1normal function, you can set a piece of data in the sprite to 4. you’re setting a global variable to 4 right now which won’t work. each time enemy gets hit you subract 1hp from their individual sprite. if you look at my game Fable of Zelba look at the functions SpawnMonsters, and DamageMonster (going by memory)

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [December 8, 2021, 11:22pm UTC](https://forum.makecode.com/t/how-do-you-give-each-enemies-their-own-health/11266/4 "2021-12-08T23:22:46Z")

</div>

Use the sprite data extension!

---

<div class="post-metadata">

**Author:** ![LcAtonal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/lcatonal/32/16800_2.png) [@LcAtonal](https://forum.makecode.com/u/LcAtonal)\
**Post date:** [December 9, 2021, 1:57am UTC](https://forum.makecode.com/t/how-do-you-give-each-enemies-their-own-health/11266/5 "2021-12-09T01:57:25Z")

</div>

I already figured out this after looking through the forum’s td game. But now I have a problem with my td game: the towers aiming at the first sprite to spawn.
