How do I allow a Module Script Table Memory to be viewable and editable via both client and server and have those edits synced?

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?

2 Likes

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.

1 Like

Why would it only be a requirement with remote events? You should be doing sanity checks on it no matter what method you implement.

Not really. You’re trying to do something hacky so naturally there isn’t going to be a non-hacky way of doing it!

1 Like

Fair enough, I’ll attempt to try and figure out a optimized and simplistic way of doing this via Remote Events, with Sanity Checks of course.

I’ll reply back if I run into any more road-blocks while attempting to do this, with this method.

1 Like

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.

FilteringEnabled = false

1 Like

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.

1 Like

Yeaaahhhhhhhhhh… That option is out of the window.

I’m just attempting to make a proof-of-concept as of the moment on how’d it would work in real-life scenarios.

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.

Going to attempt this.