Automatic Server-Client replication of Tables

Is there any way to have a kind of TableValue? (Similar to IntValue, NumberValue, StringValue, etc). If not. is there any easy way to keep all (or chosen) client(s) updated on what the Table’s content is?

1 Like

This is what i mean by values:
image

1 Like

TableValue is not a valid option as it doesn’t exist yet. If you want to keep changes of Data from the Server to the Client, there are two ways to achieve this kind of connection.

Let’s say we have a Table of Data.
{Currency = 5, Name = “Joshua”}

First is to replicate values into Instances, we can use type( ) and typeof() do detect kind of value stored in. If it’s a number, we make a NumberValue and store it somewhere in the Player instance. You should use ensure synchronization between those two values as well.

Second is to cast an value update through RemoteEvent. On LocalScript, you should try to create a global variable using something like _G and store a local copy of Player’s data, this will allow you to keep track of the RemoteEvents from only one LocalScript. In order to keep track of the data changes on the Server, you can utilizes metatables to detect when changes are made to the table - not recommended as there are limitations or you can make a special function that both modify the data and send a copy of the table back to the client.

I think ill try the second option since the first one is not that ideal when dealing with potentially hundreds of values. Thanks for the help!

2 Likes

You can use ReplicaService if you want an over the top robust replicator.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.