Problem with adding an item to inventory from an in-game shop

I have created an in-game shop (not IAP) that allows players to purchase certain items. The items are then added to the user’s inventory. To do this, I created a struct array that holds all information for each item available. These items are then populated to a umg widget button for each item in the array. When the button is clicked, a confirmation window pops up, asking them to confirm the purchase. If they hit “Yes,” the item is then sent to their inventory. This works, but it doesn’t work. It should only be adding one instance of the item to the inventory, but it is adding two. Here is my code for adding the item:


Any idea what is causing the second instance to be added? The array the temp array is appending to is empty before performing this action.

It’s too complicated to understand from just this snippet - at least for me. Just an idea - is it possible that you add one array is “purchased” and one is “Store” and maybe you put both to the inventory? At least i see the 2 arrays “Struct craft store” and “Struct Blueprints purchased” being appended, so maybe that is where the 2 come from? But for a detailed analysis I just lack the info of what is really happening here.

Basically, when the button in question is pressed, its index is assigned to the variable “index number.” It is then taking that index number from the “Struct Craft Store,” and appending it to the (currently empty) “Struct Blueprints Purchased” array. It only takes one instance of that selected index of the Store struct. Or, at least it is supposed to.

OK, that clarifies it a bit. So your snippet - what it does is read out the variable “Index number”, pull the corresponding craft store item out of the craft store array - make an array of that item and append that array to the purchased array. That last part puzzled me a bit - why are you creating a new array of a single item and append that instead of adding the single item directly - but technically what you did should work even if it seems more complicated. But OK if the Purchased array is really empty then adding your single item should still result in just one item within the array. Soooooo probably the error is somewhere else. If you still don’t believe me you can debug the array to screen (PrintString) to show all items - here’s an example of how you do that:

But I’m quite sure the error is somewhere else.