# Inventory Issue

**URL:** https://forum.makecode.com/t/inventory-issue/34814
**Category:** Help
**Created:** [March 22, 2025, 11:36pm UTC](https://forum.makecode.com/t/inventory-issue/34814 "2025-03-22T23:36:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pmaiurano](https://avatars.discourse-cdn.com/v4/letter/p/cab0a1/32.png) [@pmaiurano](https://forum.makecode.com/u/pmaiurano)
#### Post date: [March 22, 2025, 11:36pm UTC](https://forum.makecode.com/t/inventory-issue/34814/1 "2025-03-22T23:36:19Z")

</div>

I am trying to make it so you can use an inventory to get items and then use those items using the toolbar with A and B. I have everything working with the inventory, and selecting an item with A and B to set the toolbar, but when I try to make a function to use the sprite that is in the array, it is breaking the system. I was trying it the way they did on the Makecode Advanced Horticulture game, but it wasn’t working so I downloaded the inventory extension to try, but it still seems to be broken. **(See note for how to break code.)**  
Any help would be appreciated and I’m guessing its something simple I am missing. Thank you.  
[Inventory Test](https://arcade.makecode.com/S79296-34156-21567-20676)

---

<div class="post-metadata">

### Author: ![pmaiurano](https://avatars.discourse-cdn.com/v4/letter/p/cab0a1/32.png) [@pmaiurano](https://forum.makecode.com/u/pmaiurano)
#### Post date: [April 9, 2025, 6:05pm UTC](https://forum.makecode.com/t/inventory-issue/34814/2 "2025-04-09T18:05:21Z")

</div>

Ok, I have figured out the using Item issue, but now have a new issue. I am trying to search my inventory array for the name of the item that I might want to add, to see if it already exists. If it does, I want it to stack, and if it doesn’t then add a new item to inventory. I can’t figure out how to add an if statement to check the inventory for the string of item “name”. Every time I do, it seems not to like the fact that I am looking for a string on a sprite list I guess. I have tried loops, every block in the inventory along with the join block to try and turn it into a string, but have had no luck. In the picture below you can see how I am adding an item, and I think it should be a simple check for the name of new item and if it’s there add to amount… I have spent some time trying to work this out, and it is a crucial feature to move forward in a larger project I’ve been working on, so any help would be very appreciated.  
Thanks!

 ![Screenshot 2025-04-09 091316](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/d/e/debd1de177025e8fc9ab060a9a265d3bf5ad2491.png)

---

<div class="post-metadata">

### Author: ![pmaiurano](https://avatars.discourse-cdn.com/v4/letter/p/cab0a1/32.png) [@pmaiurano](https://forum.makecode.com/u/pmaiurano)
#### Post date: [April 15, 2025, 3:22am UTC](https://forum.makecode.com/t/inventory-issue/34814/3 "2025-04-15T03:22:07Z")

</div>

Problem solved. In case anyone was wondering 🙂

I made a second array that keeps track of the names, so I then could index that number to find the newItem sprite.

 ![inventory fixed](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/3/1/312f5361369affd6a28bf91f7cca04128ce8ad4a.png)
