How can I fix this "accessed none trying to read property" error?

It’s because the inventory in your character isn’t initialised.