Attempt to get lenght of a nil value (global 'inventory') HELP

Hey Guys, i’m trying to create a lua script for a safe, that players can store there items. I’ve almost finished, but im getting all the time this error when i click E to open it: Attempt to get lenght of a nil value (global ‘inventory’)
Thanks for your help.