[Solved] Issue with scope

Hi, so I’m trying to have a module script store and change an inventory on the client (there’s a server sided copy, don’t worry) The issue I have is that I have multiple scripts requiring it, setting the inventory to nil. I declare module.Inventory = nil at the start of the script so the module.init and module.GotInventory can change it, and module.GetInventory can read their changes. I’ve tried doing module.Inventory = module.Inventory or nil and using _G but those didn’t work. If I remove module.Inventory = nil from the start then module.GetInventory can’t read the changes.

module.init - defines the inventory to be {} if it doesn’t exist
module.GotInventory - a function which handles the inventory sent from the server and updates the client copy
module.GetInventory - a function that gets the client inventory copy

Any help is appreciated!

The inventory is created on the server using OOP, the client is supposed to take the server’s version of it then store it

What is setting module.Inventory to nil? What script is requiring it? What are the relevance of either of those functions? What isn’t working about your code specifically (not specified if there are errors)?

Code or a barebones repro of the code you’re working with would be appreciated. It’s hard to understand your issue with the text wall that’s been presented.

Found out what was the issue, the console doesn’t work with it but local scripts do.
It’s kind of weird, the console has been acting differently lately. Maybe it’s due to luau?

So you mean to say that your script is fine? I don’t understand your reply or your initial problem.

Yeah, it’s solved. Thanks for helping. It seemed to be an issue with the console.