# Buggy Enemies

**URL:** https://forum.makecode.com/t/buggy-enemies/32453
**Category:** Help
**Tags:** game
**Created:** [December 13, 2024, 8:50pm UTC](https://forum.makecode.com/t/buggy-enemies/32453 "2024-12-13T20:50:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sera.Bee09](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Sera.Bee09](https://forum.makecode.com/u/Sera.Bee09)
#### Post date: [December 13, 2024, 8:50pm UTC](https://forum.makecode.com/t/buggy-enemies/32453/1 "2024-12-13T20:50:33Z")

</div>

Hello! I am currently making my own game for STEM, and I’m having a few bugs. The problem I’m having is with the overlapping with my projectile and the player. When I overlap with my enemies, they’re supposed to be destroyed, and a life is taken away from the player, but all my lives are taken away, and the enemy isn’t destroyed. It’s also the same deal with my projectiles. Any help is greatly appreciated!  
Game link: [https://arcade.makecode.com/S53386-69976-26094-64741](https://arcade.makecode.com/S53386-69976-26094-64741)  
Thanks ^^

---

<div class="post-metadata">

### Author: ![Bobby5020](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bobby5020/32/16554_2.png) [@Bobby5020](https://forum.makecode.com/u/Bobby5020)
#### Post date: [December 16, 2024, 2:21am UTC](https://forum.makecode.com/t/buggy-enemies/32453/2 "2024-12-16T02:21:40Z")

</div>

The problem is luckily very simple. All you have to do is, in the overlap blocks, change the variable myEnemy to othersprite. You can do this by dragging. Then, drag the destroy othersprite block above the change life block, and it should work.  
 ![Screen Recording 2024-12-15 172435](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/1/4/142117688a514bcb07b4cffbcdd707b05e716d10.gif)  
I can’t wait to play the finished game! :princess:

–Bobby5020

---

<div class="post-metadata">

### Author: ![Don](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/don/32/17989_2.png) [@Don](https://forum.makecode.com/u/Don)
#### Post date: [December 16, 2024, 2:32am UTC](https://forum.makecode.com/t/buggy-enemies/32453/3 "2024-12-16T02:32:56Z")

</div>

You have this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/a/2/a293e0b218007f5aa0f51d63a778e7385d8da8b6.png)  
What you need is this:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/d/6/d6378a76c6190cbf16136ad6a0b34f9fd4b9d3b3.png)

The variable myEnemy will always be the last enemy created. It doesn’t matter which enemy you touch. The parameter otherSprite will always be the enemy you touched.

---

<div class="post-metadata">

### Author: ![Sera.Bee09](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Sera.Bee09](https://forum.makecode.com/u/Sera.Bee09)
#### Post date: [December 16, 2024, 6:20pm UTC](https://forum.makecode.com/t/buggy-enemies/32453/4 "2024-12-16T18:20:42Z")

</div>

That makes sense. Thank you!

---

<div class="post-metadata">

### Author: ![Sera.Bee09](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Sera.Bee09](https://forum.makecode.com/u/Sera.Bee09)
#### Post date: [December 16, 2024, 6:24pm UTC](https://forum.makecode.com/t/buggy-enemies/32453/5 "2024-12-16T18:24:50Z")

</div>

Thanks so much!
