Best way to require Module containing DataStore functions on Client

Is the best (or only) option we can use to run a Module on the Client, when you need to require the module both on the Server and Client, and it is in ServerScriptService, only to clone the module and parent it to the Player and require it from there on the Client?

Basically , It is located in ServerScriptService as I need to require it on the Server, but since the Client can’t access that should I keep 2 of the same module, one on the Server and one on the Client?

If I were to do this for several modules would there be a better method?

Note that these modules concern DataStores and contain code to write to and edit it

Just throw it into replicatedstorage? The server can read the module still from replicatedstorage since a module is client side.

I am aware of that , but is there some way I can make it so it is in ServerScriptService?

Is it a good idea to keep modules involving code for changes to DataStore in ReplicatedStorage?

There is no way a client can access serverscriptservice due to filtering enabled. The only way a client and module can read from it is for it to be in a place a client script can read it from. Else i would just suggest throwing your DataStore into a script.

1 Like

Client cant access datastores even using modules. Any attempt will result in a error.

1 Like

So basically what I want to know is , should I keep them in ReplicatedStorage or not?

They contain code to edit the DataStore and write to it, is this a suggested and recommended option?

Since the Client can’t access DataStores this way it should be safe surely?

Perhaps think about using RemoteFunctions and RemoteEvents to get the communication going and making sure the server has optimal control. Writing a module script for Data Store using the OOP technique of encapsulation is a good idea, where you can connect the set and get functions to RemoteFunctions. It might be worth adding in a server script as well which listens for the connection so it can run various sanity checks, then call upon a function from the Module once it’s verified that the Data Store transaction is legit.

1 Like

As exploiters can edit code inside client-side scripts modules are the most targeted by that. So no. You shouldn’t. I would recommend doing a normal script for your datastore

1 Like

(post withdrawn by author, will be automaticaly deleted in 1 hour unless flagged)

Im not sure what he is talking about. I have seen datastores set up in modules before and they worked but i havent personally tried it. And require asset id may work. I have never personally used it before.

1 Like

You shouldn’t replicate them to the client since clients can’t access Datastores anyway. If you do, then it will produce extra Network Traffic

1 Like

instead of merging all modular code into one script, is it better to simply use Remotes to get certain information from the DataStore and on the Client, using the Value received. But I would have to fire those events for every type of data, each time it changes.

You can use A RemoteFunction that when Invoked it gives you the value of the DataStore.

1 Like

I would just keep it on a server script. And im not sure what type of data your having to send over. If you set it up with all the value data inside the player. Then save data on leaving you should be fine. As long as your adjusting the data (ect. Money, XP) server side its non exploitable and works well.

2 Likes

If you do use RemoteFunctions a Exploiter can just spam fire the Remote to throttle your DataStore (Unless you put cooldowns in them). But why do you need to access data on the Client anyway?

What are you trying to achieve

1 Like

So like money? if so still. Your client side can access those values just the same. The only sending over you need to do ever is client to server. Client values arnt replicated on server side due to filtering enabled to stop exploiting. But when the server value is updated its replicated across client side

1 Like

You can simply update a boolValue on the server inside the Player and have a LocalScript reference the value

Edit: Also why do u need this BoolValue, maybe there is a other way to accomplish this.

1 Like

So use a .Changed event for those values, to detect when they are changed and then get the latest values (all stats, i.e “Coins”, for example, “OpenedCrate”, etc.)
and use those to update the Gui?

Is this a good idea for values that will constantly change , a lot of them?

Datastores have Rate Limits.

Yes. Thats the ideal solution

1 Like

I’m pretty sure you cant access data store service by the client.

1 Like