Recently I’ve started messing around with Module Scripts and how they are replicated.
In one of my projects I’ve came to an issue where it is required for a Table’s memory under a module script located in RepStorage to be globally editable and globally viewable by both the client and server, and that both of these edits/changes needs to be synced with other clients and the server itself.
I already understand the risks and how unsecure it may be to do this, but lets say per-chance that the security issue was thrown out of the Window or already delt with, how would I be able to do this?
You would need to make use of remote events in order to inform other clients / the server of any indended changes, as each user has their own version of the module script. Then, you’d need to carry out those changes for each user / the server.
That is indeed one way to do it, and I’ve already looked into it. But I’m attempting to figure out if Roblox Lua has any other less hacky ways of doing this that are rather more “out of the box” other than directly relying on remote events alone, since if I were to use Remote Events alone it’ll over-complicate as time goes on, and it’ll require me to do sanity checks on these remote events to prevent tampering.
If all else fails, you can always use a last ditch effort strategy!! Wouldn’t typically recommend it (if you’re a coward), but it would certainly help you achieve your goal.
This could be an xy problem. Im curious as to what this could be useful for, as there is very likely a better way to do it.
To achieve what your’re looking for you would need to use remotes as previously stated to sync the table. With higher ping users, you may run into race conditions where 2 write operations occur simultaneously resulting in data loss. (One write happens off data in original state, before data is back-synced to all clients another write operation occurs from a second client. Now, the write from the first client would essentially be lost). The manner you deal with this really depends on what you’re making.
After brain-storming over-night. I’ve had the idea of having one centralized server sided script that’ll handle the table. And allow either the client or other server sided scripts to be able to modify this table via either Binded Events or Remote Events.