Replicating Table?

I’ve started working with Tables as a way of storing Data as opposed to using large instances / folders.
The current predicament I have is replicating the Table from Server > Client & vice versa?
I can’t figure a way of creating a Module / Format that’d do this for me?

Any help would be appreciated!^^

I would never recommend asking the client for data as a exploiter can easily manipulate it, but if you do want to do it that way, use a RemoteFunction. RemoteFunctions allow you to send a request to the server and obtain a value that is returned

local function DoSomething(player: Player)
     return player
end
RemoteFunction.OnServerInvoke = DoSomething

and on the client, you would Invoke it (InvokeServer).

From the server standpoint, you can make a ClientInvoke

local function DoSomething(player: Player)
     return player
end
RemoteFunction.OnClientInvoke= DoSomething

this allows the server to run InvokeClient with the first argument being the player RemoteFunction:InvokeClient(player). The client would then send the data retrieved back to the server. Thusforth completing what you wanted. Server → Client & Client → Server

Any data that the server relies on should be kept server side (like via module script). The client can then access the data as required via remote functions/events.

1 Like

Like @PerilousPanther said, I would not recommend asking the client what they think the data is and that you should indeed just assume the data on the server just to be safe.

1 Like

I mean for the case usage of transmitting the Data to the Client.

In this case the Players Inventory, Pets etc is stored in the Server but when a battle Starts it will require the table from the Server for the Client to know the requirements.

Yep, sounds perfect. Never ask the client what to believe. Its like asking a friend for legal advice rather than a lawyer, they may know some or some type of it, but do not know the whole thing. (i.e a exploiter may give you the correct argument, but who’s to say they are the correct ones)

1 Like

How would I go about returning the Values from the Battle to the server though?

In this case say the Captures a Pet in-battle, how would that info be transferred back to the server?

You fire a remote saying you want to attempt to catch it, the server will then return a value saying if you caught it or not. Or if you don’t care about security that much, have the client calculate if you can catch it then tell the server you caught it. If you want to do the 2nd approach, but want some security, you can have a alg. that check how many catches they have caught in a row without fail.(i.e Always Catch cheat)