How to make table accessible to server and client

hello guys i have a problem. you must help fix. grrr.

so basically i have a module script and it has a function where it will add something to a table inside the module script.
Screenshot 2025-10-11 at 12.50.30 PM
i also have a function that accesses the table
Screenshot 2025-10-11 at 12.51.02 PM
the issue is that when the server adds something to this table and accesses the table, it is able to get the whole table.

HOWEVER, when the client tries to access the table full of stuff that the server put in, it returns nil.

  • server adds item A to table
  • server tries to access table
  • server gets returned {A}
  • client tries to access table
  • client gets returned {} (empty)
  • this is bad

P.S. I’m using this for a stats UI on the client to display stats @AC_Starmarine

plz help me fix guys ty

hidden text

You’re probably going to have to use a RemoteEvent. Module scripts (as far as I know) do not share data between the server and the client.

2 Likes

oh, well the thing is this is mainly for a ui on the client that updates stats 10 times a second, so firing 10 remote events per second might be too much

actually i COULD use unreliable remote events is that a good idea chat?

You could convert your table into a string using HttpService’s EncodeJson and then set that to a string value in workspace. Then on your client, you could constantly read from that string value, and use the DecodeJson function to turn it back into a normal lua table.

2 Likes

thanks @EffBeeCee and @AC_Starmarine, I’ll try both of your solutions when i have time and see which one works best for my scenario.

What type of data will be sent over to the clients? What is your intended use case?

Module scripts that are required by the server and client are diffrent.

If the server requires a Module script, said script runs and returns all of it’s code to the script that required it while also creating a cache to store the returned value for optimization. said cache is network exclusive, so the server’s returned script is difrent from the client’s

I would recommend using RemoteEvents along with some form of compression/optimization to lower Network load.

Knowing the type of data and his use case for the data makes the next step easier to figure out.

Also how much data.

as long as payloads aren’t larger than 8000 bits:

Events with payloads larger than 1000 bytes are dropped.

Could It be possible to use RunService:IsServer() and/or RunService:IsClient() to make a table only function with one of those?

1 Like

your solution was the closest to the one i did

  • basically i wanted stats (similar to leaderstats) to show up on a client ui without being on the actual leaderboard so i just made a folder called stats under the plr
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.