# Placing and Removing Sprites on Specific Tiles

**URL:** <https://forum.makecode.com/t/placing-and-removing-sprites-on-specific-tiles/13209>\
**Category:** Help\
**Created:** [April 21, 2022, 4:50pm UTC](https://forum.makecode.com/t/placing-and-removing-sprites-on-specific-tiles/13209 "2022-04-21T16:50:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoMustangs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gomustangs/32/4323_2.png) [@GoMustangs](https://forum.makecode.com/u/GoMustangs)\
**Post date:** [April 21, 2022, 4:50pm UTC](https://forum.makecode.com/t/placing-and-removing-sprites-on-specific-tiles/13209/1 "2022-04-21T16:50:11Z")

</div>

Here’s the game code: [https://makecode.com/\_Ja5XaaXRzV9z](https://makecode.com/_Ja5XaaXRzV9z)

I’m using this code to place specific sprites on specific tiles in the function the builds Level 3:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f3ba69d7beb7aca145c08cc9f818814413bcf8bb.png)

I’m using this code to destroy the previous level’s sprites and set up Level 4:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/499ed13f5033c7d163e78bc6bb4b881c57915466.png)

The problem is that the sprites I need destroyed are staying on the screen when Level 4 starts.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c91264fc004fcb07908e22e4f3c328bdb1b3e9f8.png)

Can anyone tell me why this is happening, or suggest how I can fix it?

Thanks!

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [April 21, 2022, 4:59pm UTC](https://forum.makecode.com/t/placing-and-removing-sprites-on-specific-tiles/13209/2 "2022-04-21T16:59:24Z")

</div>

Because you’re creating the enemies in a loop, the variables are getting reassigned to always point to the last instance of each enemy being created. Your code will only destroy the last enemy created by each of those loops.

I think you might have more luck if you use the “destroy all sprites of kind” block in the sprites category instead of trying to destroy the variables:

![Screen Shot 2022-04-21 at 9.56.16 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1f36e3310803031a8613935e4fd21b60c252c7ee.png)

---

<div class="post-metadata">

**Author:** ![GoMustangs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gomustangs/32/4323_2.png) [@GoMustangs](https://forum.makecode.com/u/GoMustangs)\
**Post date:** [April 21, 2022, 6:50pm UTC](https://forum.makecode.com/t/placing-and-removing-sprites-on-specific-tiles/13209/3 "2022-04-21T18:50:46Z")

</div>

Thanks! That seems to have fixed the problem!
