More efficient server-client data model?

  1. What do you want to achieve?
    A better method of sharing data between the server and one client.

  2. What is the issue?
    Currently, my scripts involving my current server-client data system have been very very painful to do. The system is the most painful with items, as all items are custom (each is a table and unfortunately cannot be easily compared to another table) and both the client and server have separate data to prevent any lag (the client is updated when needed and can only read the data).

  3. What solutions have you tried so far?
    Honestly, I didn’t really look too hard for solutions besides trying to think of something (and failing). I don’t really expect many games to handle items the same way they are in my game so in most other games it’s probably a fine method.

Better explanation of my current system:

  • The server has a global data module script, containing 1 table for each player, which is further divided into more tables as this is all of the player data in one huge table.
  • Each client uses a module script and updates it locally so that no other client can see another client’s data. This means if you have a high ping like 500 ms, you don’t have to wait half a second to receive data unless it’s just been updated.
  • The client never modifies their own data other than to update it, all requests are sent to the server which processes it and then sends back an updated piece of the data.

And the current problem with this is:

  • As mentioned earlier, it is incredibly painful to work with.
  • This is because everything has to be passed through a bunch of functions for literally everything, and also because you cannot locate an item very easily. An item on the client is not on the server, the server simply has a copy, therefore, attempting to compare “itemA == itemB” where the first is from the client and the second is from the server, will always be false even though both items are the same in content.
  • Additionally, setting a value and forgetting to run certain things basically just doesn’t update the client which can lead to undetectable errors when the client is missing something they should have.
  • There are many other issues with it too, which is why I have made this post to look for a better method.

The optimal method in my opinion would be a shared module where a singular player and the server can access it (though still server-side so the client can’t modify their data illegally), and each player being able to have a shared module with the server which would mean you could be able to compare “itemA == itemB” without it being false every time.

Of course, the main issue is probably my programming skills, the methods I used probably aren’t the greatest but it would be a huge time saver if there was any better way to solve this.

Have you considered something like ProfileService? It seems like a lot of your structure closely matches how it works, but it also has the added benefit of having a central data saving system with individual profiles.

The issue is that you’re always going to have to have a server/client divide to stop bad actors. I think the general rule of thumb is that you keep everything computationally intensive on the client, and then do necessary checks and data changes on the server. You can make a fairly neat web of remote events/functions doing this. I think holding data client side should only ever really be for unimportant mechanics, otherwise I don’t see a scenario where you couldn’t achieve the same outcome with events.

Thank you for the response, though I think you might’ve misunderstood a small part.
All “real” data is server-side, the client only has a read-only copy which the server cannot receive, the client only uses this copy to check values so it doesn’t have to ask the server for data every time. All editing, besides the client receiving the new data from the server, is done by the server and the client can only send a request to the server if they want to edit something. The main issue is that since they’re both separate, the server will not recognize any table (such as an item) sent from the client. This leads to lots of undesirable effects such as requiring the server to check every value in every single item just to find which one the client is referring to, so coding things to make up for this can be rather difficult.

However, this ProfileService does seem rather promising so thank you again for showing me this.