replication
replication provides typed, reactive player state that the server owns and
replicates to each player's client. Nothing is saved between sessions.
Installation
pesde add twistedsignal/replication
Setup
local Replication = require(path.to.Replication)({
template = {
currency = 0,
inventory = {} :: { string },
},
})
return Replication
On the server, access a player's state through Replication.server[player].
On the client, use Replication.client.
Replication.server[player].currency(50)
print(Replication.client.currency())
The server can update nested values, insert or remove array entries, and skip a
specific network update by passing false as shouldReplicate. Client writes
only change the local mirror.
Each value exposes changed, observable, onKeyAdded, and onKeyRemoved.
Array values also expose insertArray, removeArray, onArrayInserted, and
onArrayRemoved.