# How do i make an enemy attack the closest player?

**URL:** <https://forum.makecode.com/t/how-do-i-make-an-enemy-attack-the-closest-player/36717>\
**Category:** Help\
**Created:** [May 16, 2025, 10:45pm UTC](https://forum.makecode.com/t/how-do-i-make-an-enemy-attack-the-closest-player/36717 "2025-05-16T22:45:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deastor\_Ray](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Deastor\_Ray](https://forum.makecode.com/u/Deastor_Ray)\
**Post date:** [May 16, 2025, 10:45pm UTC](https://forum.makecode.com/t/how-do-i-make-an-enemy-attack-the-closest-player/36717/1 "2025-05-16T22:45:48Z")

</div>

Im trying to make a 2 player game, but i made some creatures and they cant attack the closest player… Can someone tell me how to make them attack the closest player please?

---

<div class="post-metadata">

**Author:** ![redSprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/redsprite/32/34262_2.png) [@redSprite](https://forum.makecode.com/u/redSprite)\
**Post date:** [May 16, 2025, 10:51pm UTC](https://forum.makecode.com/t/how-do-i-make-an-enemy-attack-the-closest-player/36717/2 "2025-05-16T22:51:50Z")

</div>

Try

```auto
jwunderl/arcade-sprite-util

```

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [May 17, 2025, 3:15am UTC](https://forum.makecode.com/t/how-do-i-make-an-enemy-attack-the-closest-player/36717/3 "2025-05-17T03:15:40Z")

</div>

RedSprite gave you an extension. If you put that text into the extensions search bar, you’ll see the Sprite Utils extension. I think this extension has blocks for finding the closest Sprite and stuff, so that’s why it was recommended you take a look. If there isn’t a dedicated “closest Sprite” block, you can use the blocks that check the distance between two sprites to check which player Sprite the enemy is closest to.

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [June 12, 2025, 9:53pm UTC](https://forum.makecode.com/t/how-do-i-make-an-enemy-attack-the-closest-player/36717/4 "2025-06-12T21:53:44Z")

</div>

i made a tutorial on this if you are still interested  
[[Tutorial] Making an Enemy Follow Multiple Sprites :snake:](https://forum.makecode.com/t/tutorial-making-an-enemy-follow-multiple-sprites/33914)
