Array error when I drop more than one item from inventory

Hey everyone.

So I have hit rock bottom trying to figure out what is going wrong with my blueprint. I have this fairly dynamic inventory/crafting system going on, which I’m following from a tutorial (Create a Crafting & Inventory system in Unreal Engine 4 Pt 7 Populate Crafting Recipie Lists & Data - YouTube). Problem is, (I’m guessing partly since the tutorial is 6 years old…) I’ve hit a bunch of array errors. I’ve managed to fix a lot of them along the way, but the one that still persists is when I drop or interact (eat) an item and removes it from my array again I get array and access none errors.

The funny thing is that I can drop one item - lets say a sword, or a box - once for each without the error triggering. But if i drop lets say 2 boxes the error will trig.

If anyone has the time to go over the screenshots I’ve linked, I would be so happy.

The error I’m getting:

Blueprint Runtime Error: “Attempted to access index 0 from array Inventory of length 0!”. Blueprint: W_InvMain Function: Item Name Text Getter Graph: ItemNameTextGetter Node: Return Node
Blueprint Runtime Error: “Accessed None reading structure ItemName_2_059D7BF849656A406DC94293281AFA91”. Blueprint: W_InvMain Function: Item Name Text Getter Graph: ItemNameTextGetter Node: Return Node
Blueprint Runtime Error: “Attempted to access index 0 from array Inventory of length 0!”. Blueprint: W_InvMain Function: Item Weight Getter Graph: ItemWeightGetter Node: Set ItemWeightTemp
Blueprint Runtime Error: “Accessed None reading structure Weight_5_C47948BE4533BB1E88B226969399C5B8”. Blueprint: W_InvMain Function: Item Weight Getter Graph: ItemWeightGetter Node: Set ItemWeightTemp
Blueprint Runtime Error: “Attempted to access index 0 from array Inventory of length 0!”. Blueprint: W_InvMain Function: Item Details Getter Graph: ItemDetailsGetter Node: Return Node

Screenshots:
The main function screen: https://i.imgur.com/ZAKxZgv.png
The add item/stack loop: https://i.imgur.com/6j33rHw.png
The drop logic: https://i.imgur.com/yIrlRtI.png
The automated details system that pops up along with the selected item (there is one for item name and weight as well): https://i.imgur.com/hOl02vQ.png

ok so the error isnt coming from any code in those screen shots according to the error message you posted the errors are coming from the following functions <<<< 1. Function: Item Name Text Getter 2. Function: Item Weight Getter 3.Function: Item Details Getter anything in there that are binding to the UI need to run a is valid check and only fire off if an item is valid if you could screenshot those 3 functions i can walk you through exactly what is failing or just check if its a binding function it checks for a valid item before trying to return a text or image for an item that no longer exist.

so i just notice the item getter screenshot of the item getter function on the false branch you have run a for each loop of the inventory array off the inventory and hook array element run a Is Valid Index
and array index into the integer and is valid index into a branch and if true hook up to the return node
and the item details should come from the array element of the loop. if false leave blank.

Thank you for the answer. So that makes sense. I used to have a isvalid code in there as well, but that seems to just stop the code from running. And I tried your idea, which stops the error from happening, but now the code isn’t running. Hmm… Does this make sense to you?

Oh sorry, I must have disconnected the loop body on that screenshot. Anyways, it worked!!! Thanks a bunch, that was really helpful.

ya sorry hook Loopbody to the branch after is valid and remove the make array and just hook your inventory to the is valid index and off array element hook that into the S_ItemData on the break and remove the Get

no worries!! if you need any more feel free to ask .