Reaching a table from both the client and the server

I am making a game that involves a system for unlocking items. I am currently using a table to remember what items they have unlocked, but that table needs to be accessed in multiple scripts on the server and one on the client. One solution is to have both a bindableEvent and a remoteEvent for accessing the table, but I don’t really like that solution. Any suggestions, or should I use a different unlocking system altogether?

You could easily use RemoteFunctions to accomplish this, but I would use a ModuleScript, because they can easily be accessed by all scripts, and are perfect for handling data.

1 Like

I didn’t realize you could do it with a modulescript. I’ll try that.

1 Like

Sorry, my understanding of modulescripts isn’t very good. Could you explain how to do it in more detail? Thanks!

Do you need the values to save between the player’s visits as well?

I do. (30 charssssssssssssssssss)

Here is a wonderful article that explains the subject in much depth:

I don’t know if that will replicate…

What so you mean? It works based off of DataStoreService. It is recommended that you always get/save data via the server, so if you needed the data on client, you could obtain it using a RemoteFunction request.

yeah but if you alter data on the client how will that replicate

You never should try and alter data on the client. That is a huge development no-no, because it could lead to exploiters changing important values that they shouldn’t be able to , such as a player’s money or experience.

  1. Never trust the client.
  2. If you’re letting the client alter data, send a remote event/function and have anti-exploit measures on the server side.
  3. You can use a remote function that can return data from the server after something is sent to the client.

I know that already, that is not what I am saying. I am saying that changing stuff on the client doesn’t replicate first of all, and second of all, I am saying that you can simply not communicate using a table in a local script both ways since it doesn’t replicate from client to server. You can, however, replicate from server to client just fine on most things, and I think that @7grandnec should go more into depth on which ways he needs to communicate (server to client only, client to server only, or both).

So in a short sense I was not talking about altering data on the client, I was actually saying that wouldn’t work to start with.

You get the information on the client, by implementing a RemoteFunction, which is a way of requesting information to be returned to the client, or vice versa.

Did you just hear what I said? L O L

I said I A L R E A D Y K N O W H O W S E R V E R C L I E N T C O M M U N I C A T I O N W O R K S

You closed your post by saying “that it won’t work to start with”. I just wanted to make sure that people did not take this, as saying it was impossible. You made it sound like it could not be done by any means. Sorry if I misunderstood.

I’m sure you know about RemoteFunction’s already, but I was mentioning it for the sake of others who don’t

It’s alright, I just want you to know that I didn’t mean that. I am only saying that client to server will not work using a module script, but maybe using some remote functions and remote events will help the situation.

So in short, @7grandnec I think you might consider using RemoteFunctions as they allow for returning.

1 Like