Inventory problem Error (Accessed None 'InventoryWidget'...)

Hello, basically I’m trying to add a inventory system to my game, but I’m not very good at scripting so I am trying to replicate this inventory system from this video;

Everything seemed to work, until I got to epizode 6, Errors are coming up when I try to open my Inventory. From what it says in the error, something is wrong with this blueprint (at least I’m guessing)
I really need a fix for this, I would really appreciate someone’s help. thanks.

If your boolean variable CanMove is already false before your InventoryWidget is created and applied to InventoryWidget variable then your will get a null reference exception when attempting to access it as is described by the error.

I recommend you shift your CreateWidget logic to BeginPlay and then just AddToViewport when the inventory is accessed.

This way your not always creating a new Widget Object when opening the inventory and you avoid the case whereby your boolean variable is false and the Widget Object is never created.

Sorry for my very poor understanding of scripting language, can you please explain what should I do in a bit less scripting language way :slight_smile: or just show me what I should do.

Here is a better implementation. Instead of shifting alot of Code around, just check that your Inventory exists first as you can see by the comments. If it doesnt exist, then create it. The logic after that is the same as you have above.

Let me know if you have further trouble.