Inventory system working but keep giving error message

Hello, I really can’t find where/ how to fix my inventory system, well it’s actually working but it’s seems like it’s trying to pull out information and doesn’t get the information back? But I can open the inventory, pick up item, drop item, etc…

The 4 line of error bellow are just the 4 first out of hundred that it generate with the only difference been the # of the item…

I’m adding pictures below as of where the error seems to be pointing out…

  • Blueprint Runtime Error: “Attempted to access index 3 from array Array of length 3!”. Blueprint: UI_Inventory Function: Set Widget Style Graph: SetWidgetStyle Node: SetText (Text)
  • Blueprint Runtime Error: “Accessed None reading structure ItemName_15_6ABA1EF243384D07FAFDDCABB6E01C04”. Blueprint: UI_Inventory Function: Set Widget Style Graph: SetWidgetStyle Node: SetText (Text)
  • Blueprint Runtime Error: “Attempted to access index 3 from array Array of length 3!”. Blueprint: UI_Inventory Function: Set Widget Style Graph: SetWidgetStyle Node: Set Style
  • Blueprint Runtime Error: “Accessed None reading structure ItemImage_16_714B4D2545966E5730113D8345478AAB”. Blueprint: UI_Inventory Function: Set Widget Style Graph: SetWidgetStyle Node: Set Style

You’re trying to access the forth item ( index 3 ) of an array of length 3. So, it’s not there, and you get a ‘none’.

I don’t know what in particular is wrong with your code, but I do see a REMOVE INDEX there. Are you up to speed with the face that you can’t loop over an array if you have REMOVE INDEX happening at the same time?

This is because the loop gets confused about how many things are in the array.

You can, however, remove indexes if you only ever remove the last one.

I’m new to UE4 and I honestly didn’t know about the loop over an array…

I’m not sure how I understand how to make to remove indexes only if removing the last one?!

Sorry, I typed that a bit hurriedly… What I meant was, don’t remove indices while you’re looping over an array, unless you loop backwards, and remove them as you go.

IE, loop from the end to the beginning.

To do that, you have to copy the loop macro, and make yourself one that goes backwards.

I don’t know if this is your problem, but if you use a normal loop, and remove and items, it will not work as you expect.

Hey sorry for the late reply and I appreciate your help, It’s still giving me the error but the gameplay doesn’t seem to be impacted and it’s working as intended.