Accessed None Error with Switch node

Hello,

I’m trying to set up an inventory system which can keep track of different types of ammo and quantity. I’m trying to make a function that loops each item in the inventory, checks the ammo type of each item, adds the quantity together so i get a total for each ammo type. The best i came up with so far looks like this:

what the ammo struct looks like:

defaultvalues

When I print text it seems to work only for the M1Ammo, as I pick up or remove M1Ammo from my inventory it will show the correct numbers. However, for the Molotov ammo, it prints out 4x of what I have in my inventory. So I have 4 molotovs in my inventory, for some reason it prints out 16. I get this error:

it repeats a lot. I’m not sure what I am doing wrong, I checked the ammo variables and they are correct, they are taken from a data table. I appreciate any advice, I’m not sure how to fix it or if there is a smarter way to do it. Thank you for your time

Update: setting the Array Element to a variable and adding a “IsValid” Node after “For Each Loop” removes the error, but the issue of molotov quantity being wrong still remains

Figured it out. My inventory system has icon sizes and this seems to multiply the ammo quantity. Closing

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.