# Item loses it's properties when another spawns

**URL:** <https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803>\
**Category:** Help\
**Created:** [December 5, 2023, 7:25pm UTC](https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803 "2023-12-05T19:25:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![OneBigGoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/onebiggoof/32/13823_2.png) [@OneBigGoof](https://forum.makecode.com/u/OneBigGoof)\
**Post date:** [December 5, 2023, 7:25pm UTC](https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803/1 "2023-12-05T19:25:02Z")

</div>

I’m trying to make a game, where when you defeat an enemy, it drops an item. And when there’s only one item that’s spawned, it works fine, but as soon as another item spawns the first item that was spawned doesn’t work anymore and just floats there. I would send the code (and I still might) but it’s a mess at the moment.

---

<div class="post-metadata">

**Author:** ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)\
**Post date:** [December 5, 2023, 7:27pm UTC](https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803/2 "2023-12-05T19:27:19Z")

</div>

Welcome, @OneBigGoof !

There are a few reasons this might be, so you’re right that sending us a link would help greatly. It’s okay if the code is messy, most of us here are used to that. Just go ahead and share the URL for your game and we’ll help debug!

That said, can you tell us more about what you mean when you say “doesn’t work anymore”? What kind of events are you trying to make it respond to?

---

<div class="post-metadata">

**Author:** ![OneBigGoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/onebiggoof/32/13823_2.png) [@OneBigGoof](https://forum.makecode.com/u/OneBigGoof)\
**Post date:** [December 6, 2023, 3:00am UTC](https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803/3 "2023-12-06T03:00:55Z")

</div>

here’s a link to the code: [https://makecode.com/\_AA6dTua7E739](https://makecode.com/_AA6dTua7E739). I tried to clean it up just a midge, and I put the code that is used for the item spawns with each other so you don’t have to hunt it down. What I was meaning by “doesn’t work anymore” is that, when another item is spawned, the previous item that was spawned before that item stops being able to be touched. It can’t be interacted with or collected and is just a floating sprite.

---

<div class="post-metadata">

**Author:** ![OneBigGoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/onebiggoof/32/13823_2.png) [@OneBigGoof](https://forum.makecode.com/u/OneBigGoof)\
**Post date:** [December 6, 2023, 3:01am UTC](https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803/4 "2023-12-06T03:01:09Z")

</div>

forgot to mention how the game works. you press A to jump and B to throw rocks. you can step on snakes and bats but for crabs (at least I think they’re crabs?), you have to throw rocks to defeat them.

---

<div class="post-metadata">

**Author:** ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)\
**Post date:** [December 6, 2023, 3:12am UTC](https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803/5 "2023-12-06T03:12:20Z")

</div>

Alright, I think there are a few things going on here. For example, you have both variables and kinds named “item”. I think that’s causing issues.

Also, can you explain a little more about why you chose to do overlaps this way:  
 ![Screenshot 2023-12-05 at 7.05.21 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/10444f0c1b0941b05ad40e370ea6efec859462e8.png)  
instead of this way?  
 ![Screenshot 2023-12-05 at 7.05.29 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/58a1bef1359ca21af710b6b8e14bd3dfeed37440.png)

Personally, I’d also use the [sprite data extension](https://medium.com/kikis-corner/asd-5e3cbce2ead9) to keep track of the properties on these drops. It will make things a lot more simple for you!

---

<div class="post-metadata">

**Author:** ![OneBigGoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/onebiggoof/32/13823_2.png) [@OneBigGoof](https://forum.makecode.com/u/OneBigGoof)\
**Post date:** [December 6, 2023, 8:39pm UTC](https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803/6 "2023-12-06T20:39:42Z")

</div>

I think I may have found a fix for it. I may just have to create two different “kinds” for the items. I had tested it to instead just destroy “othersprite” instead of “RockDrop” and it seemed to have worked, since both items stayed and could be interacted with. So I guess now I just have to make a kind for the banana and the rocks.

---

<div class="post-metadata">

**Author:** ![OneBigGoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/onebiggoof/32/13823_2.png) [@OneBigGoof](https://forum.makecode.com/u/OneBigGoof)\
**Post date:** [December 6, 2023, 8:48pm UTC](https://forum.makecode.com/t/item-loses-its-properties-when-another-spawns/24803/7 "2023-12-06T20:48:26Z")

</div>

I had tried to do it with the “on sprite of kind overlaps” block, but it would for some reason cause the previous item to not get destroyed when there were two of the same items in the game, which would cause the game to give the player infinite amounts of that item when touched. So I had tried to do it the same way I did with the enemies, by giving each item their own commands, but it just caused the problem that I’m having now.
