I am getting an error and would know how to fix it,

Everything is working as intended but I am getting this error:

Blueprint Runtime Error: “Attempted to access index 0 from array Inventory of length 0!”. Node: Update Quantity Graph: Add Item Function: Add Item Blueprint: InventoryComponent

This is my code:

Add Item Bp posted by anonymous | blueprintUE | PasteBin For Unreal Engine

What do I need to do to get rid of the annoying error?

Hey @veevogames1!

You need to post the insides of those custom functions! What’s happening is you’re trying to get an index of the Inventory array that isn’t there, giving you a null reference exception. Which, if this code is correct, shouldn’t happen UNLESS the bool output of your previous function was backwards. Give looking into that a go!

1 Like

Here is the check existing item function:
Check Exsisting Item function posted by anonymous | blueprintUE | PasteBin For Unreal Engine

and here is the UpdateQuantity Function

Update Quantity Function posted by anonymous | blueprintUE | PasteBin For Unreal Engine

Not sure what’s going on I’m so confused and been trying to get this working since 7am this morning… any help would be appreciated

EDIT: ADDED THIS BIT OF CODE:


Now it’s fixed…

1 Like