# How to Make Code Work Together

**URL:** <https://forum.makecode.com/t/how-to-make-code-work-together/29388>\
**Category:** Help\
**Tags:** game\
**Created:** [June 21, 2024, 4:27pm UTC](https://forum.makecode.com/t/how-to-make-code-work-together/29388 "2024-06-21T16:27:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GotMilk](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@GotMilk](https://forum.makecode.com/u/GotMilk)\
**Post date:** [June 21, 2024, 4:27pm UTC](https://forum.makecode.com/t/how-to-make-code-work-together/29388/1 "2024-06-21T16:27:40Z")

</div>

Hi, I want to make enemies that can spawn on a specific place and then follow the player when they enter its radius. I have code for each feature that wok on their own, but when I try to add them to the same project they don’t work. I’d appreciate any advice or tips on why this isn’t working and how to fix it. I don’t mind having to make completely different code.

Game Link: [https://arcade.makecode.com/S06666-01683-09087-05960](https://arcade.makecode.com/S06666-01683-09087-05960)  
(block code)

---

<div class="post-metadata">

**Author:** ![User7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/user7/32/16035_2.png) [@User7](https://forum.makecode.com/u/User7)\
**Post date:** [June 21, 2024, 5:56pm UTC](https://forum.makecode.com/t/how-to-make-code-work-together/29388/2 "2024-06-21T17:56:05Z")

</div>

Enemies spawn and will follow the player if that’s whats supposed to to happen

> **[game 1](https://arcade.makecode.com/S16597-31483-75401-89839)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<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:** [June 21, 2024, 7:01pm UTC](https://forum.makecode.com/t/how-to-make-code-work-together/29388/3 "2024-06-21T19:01:28Z")

</div>

Use the sprite utils extension:  
jwunderl/arcade-sprite-util  
copy this into your search on the extension page.  
there should be a block that checks for sprite distance from another sprite.

---

<div class="post-metadata">

**Author:** ![GotMilk](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@GotMilk](https://forum.makecode.com/u/GotMilk)\
**Post date:** [June 21, 2024, 7:01pm UTC](https://forum.makecode.com/t/how-to-make-code-work-together/29388/4 "2024-06-21T19:01:49Z")

</div>

Thanks!
