Variables in ModuleScripts updated through the server receives differently on client

I’m trying to create a shop that let people purchase animations. And I store the animations the player owns in a table inside a modulescript but when the LocalScript reads the table, it doesn’t update.
This is the ModuleScript functions:

This is the script that I run on the ServerScript:

and this is what I run on the LocalScript:

This is the output I got:
As you can see, the module updated the table as the server requested. Yet, the localscript does not see it and still see the table as 0.

This is the first time I see something a LocalScript can’t receive something updated by the Server. Is this a bug? Or is there something I could do to fix it? :confused:

Edit: I did some researching and found another topic that has the exact same problem that I do:



Requiring the script from client and server grants two different scripts. The client receives their own “copy” of the module and the server for themselves.

You can use remotes, specifically RemoteFunctions, to obtain the value from server. Hook the the function with a return and you’ll be good to go.

I had the same idea of using RemoteFunctions until I forgot the fact that the data I’m trying to store for the player is a “table”, so I don’t know where to store the data on, the only place I could’ve think of is a ModuleScript so the table can be updatable by the server and receivable from the player. But during requirement the module creates a different copy so I am having trouble with it.

In that case, read about the limitations:

No mixed tables can be passed without losing them in action. Read below “Mixed Tables” and you’ll find out how to work around it.

How/Where would I store the “table” for each player in the server?

For my method of storing the table for each player, I’d choose a table which work like this:

local session = {}

	session[player.UserId] = {} -- blah blah blah loading

	session[player.UserId] = nil -- removing reference

This uses the Player.UserId as key per player.

1 Like