# Item doesn't get added to inventory

**URL:** <https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [May 10, 2020, 6:01pm UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246 "2020-05-10T18:01:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikester4411](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mikester4411](https://forums.unrealengine.com/u/Mikester4411)\
**Post date:** [May 10, 2020, 6:01pm UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246/1 "2020-05-10T18:01:51Z")

</div>

Hi, I’m trying to make an inventory system and for some reason when I walk over an item it’s not getting added to the inventory, I’ve ran the game and it all flows up to the ‘Add’ node. It’s meant to be searching the inventory of the player that walks over it, if it doesn’t find an entry in the inventory with that name it adds the item to the inventory as a new array entry, but for some reason it’s not getting added.

 ![InventoryHelp.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/0/e00ba56f18b6b6dd8cc7cc5e957e307aa3919ca4.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 10, 2020, 6:14pm UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246/2 "2020-05-10T18:14:34Z")

</div>

> [@](#):
>
> but for some reason it’s not getting added.

The array does not increase in size or the newly added struct contains unexpected data?

Or perhaps you were expecting the Third Person Character’s \*Inventory \*array to be modified - that’s not going to happen since you’re working on a copy of the array here.

---

<div class="post-metadata">

**Author:** ![Mikester4411](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mikester4411](https://forums.unrealengine.com/u/Mikester4411)\
**Post date:** [May 10, 2020, 6:18pm UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246/3 "2020-05-10T18:18:08Z")

</div>

> [@Everynone](#):
>
> The array does not increase in size or the newly added struct contains unexpected data?

The array doesn’t increase in size, by default I have nothing in the inventory, but this is supposed to add the item to the inventory when stepped on and instead it does nothing, returns no errors or anything

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 10, 2020, 6:32pm UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246/4 "2020-05-10T18:32:40Z")

</div>

Are we talking about _Player Inventory Reference_ here - you called it a reference but it’s not, it’s a copy. You keep adding elements to the copy, and the changes do not propagate back to the TPP.

---

<div class="post-metadata">

**Author:** ![Mikester4411](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mikester4411](https://forums.unrealengine.com/u/Mikester4411)\
**Post date:** [May 10, 2020, 6:43pm UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246/5 "2020-05-10T18:43:31Z")

</div>

> [@Everynone](#):
>
> Are we talking about _Player Inventory Reference_ here - you called it a reference but it’s not, it’s a copy. You keep adding elements to the copy, and the changes do not propagate back to the TPP.

Ah right, I see where I wen’t wrong, I’ve fixed it now, thank you! 😃

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 10, 2020, 7:15pm UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246/6 "2020-05-10T19:15:48Z")

</div>

Structs are nasty like that. 😑 You need to insert them back in the original array as even \*For Loop \*creates a copy of the iterated struct already. The _Set Members in Struct_ node helps a little but working with structs arrays is full of gotchas.

Good luck with the rest!

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [May 10, 2020, 10:06pm UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246/7 "2020-05-10T22:06:16Z")

</div>

Out of curiosity… instead of setting a boolean on branch(true) why not simply add to the item to the target → inventory, then break. Completed doesn’t have to execute anything.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_deb0406f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_deb0406f](https://forums.unrealengine.com/u/anonymous_user_deb0406f)\
**Post date:** [May 11, 2020, 3:05am UTC](https://forums.unrealengine.com/t/item-doesnt-get-added-to-inventory/143246/8 "2020-05-11T03:05:00Z")

</div>

Probably because there are more code and logic after adding item to the inventory…and maybe he need to know if the item is added or not. I would almost always break the loop and connect with “completed”, specially in functions with return node. However, when you break the loop, Completed node is executed.
