ModuleScripts & Replication

If I have a module script that has this source code

local dynamicPotions = {}

return dynamicPotions

Now let’s say I add something to it on the server.

table.insert(dynamicPotions, 1)

Assume a client has already required this module script, does the client’s memory also receive a replication of the new value in the module’s table? Or does that table insertion only affect server-sided requirements of that module?

The client will not know of the new value. Each environment (client, server) will have called require on the module separately, and will have it’s own instance of the returned value. If you were to print the module’s table on both the client and server, you’ll see they have different memory IDs.

2 Likes

Thanks, that’s better to know. Allows me to have client’s request to know about dynamic items player’s create in-game rather than have them replicate possibly hundreds of values without control.