Why is not working after Z key enter to add member into array structure?

I set two array (two member) into info structure so it has two member to show two button in viewport. I want to add member (addmember event) to insert info array when pressing ‘Z’ keyboard. It was supposed to get three member. But after Z enter and then I key enter (to show inventory) it dose not show up three member. I,m getting error log. Blueprint Script are give below there.

What is this issues and what is best way to solve it?

Info member Array

HUD

Mychar

Viewport to view Inventory

Errorlog

But after Z enter and then I key enter
(to show inventory) it dose not show
up three member. I,m getting error
log. Blueprint Script are give below
there.

  • if you’re doing it in this order, you’re AddingMembers to an inventory that does not exist, you’ve yet to create it - hence the errors
  • if you keep pressing I to create / remove the inventory, you’re actually creating a brand new inventory every time you press and destroying the old one

  • you’ve created the Inventory reference variable - use it; avoid pulling data from Return Value - there’s no guarantee the data is valid
  • we can’t see the critical bit here - what does AddMember do?

But it’s the first 2 bullet points, most likely.

Try it like this:

  • this way the inventory will be created if it does not exist, no matter whether it’s opened or not
  • adding item to a non-existing inventory, creates it first and only then adds a member
  • it’s more efficient to show / hide rather than add / remove from viewport

Although, I’d probably just do this:

Thank you very much