Skip to main content

TableReplicator

Replicates TableManager instances from the server to clients. A ServerReplicator wraps a TableManager, decides which players can see it, and mirrors every write to a matching ClientReplicator on each targeted client.

Access the API through TableReplicator.Server (server) or TableReplicator.Client (client).

Server

local ServerReplicator = require(Packages.TableReplicator).Server

Players.PlayerAdded:Connect(function(player)
	local replicator = ServerReplicator.new({
		Namespace = "PlayerData",
		Data = { Coins = 0 },
		ReplicationTargets = player,
	})

	replicator.Manager:Set("Coins", 100) -- automatically replicated

	player.Destroying:Connect(function()
		replicator:Destroy()
	end)
end)

Client

local ClientReplicator = require(Packages.TableReplicator).Client

-- Register listeners before requesting data to catch replicators in the snapshot.
ClientReplicator.ForEach("PlayerData", function(replicator)
	replicator.Manager:Observe("Coins", function(coins)
		print("Coins:", coins)
	end)
end)

ClientReplicator.RequestData()

Exported Types

  • ServerReplicator
  • ClientReplicator
  • BaseReplicator
  • Replicator
  • ReplicationToken
  • ReplicationTargets
  • SearchCondition
  • Tags
  • FireMode

Types

ReplicationToken

type ReplicationToken = {Namestring}

An optional, opt-in handle that exclusively owns a namespace name for its lifetime. Tokens are created with ServerReplicator.TOKEN("MyToken") and enforce collision safety: no other token or raw-string replicator may claim the same name while this token is alive.

Tokens are optional — a Namespace can be a plain string without a token. Use TOKEN() only when you need the collision guard.

To release ownership, call ServerReplicator.TOKEN.destroy(token) after all replicators using this namespace have been destroyed.

ReplicationTargets

type ReplicationTargets = "all" | Player | {Player}

The Player(s) that a top-level replicator should replicate to. "all" replicates to all current and future players.

FireMode

type FireMode = "immediate" | "deferred" | "bindable"

Controls how discovery listeners (ReplicatorCreated, ForEach, OnNew) are scheduled when a matching replicator is found:

  • "immediate": runs right away, on a new thread (like Signal:Fire).
  • "deferred": runs at the end of the resumption cycle (like Signal:FireDeferred).
  • "bindable": mirrors BindableEvent behavior for the current Workspace.SignalBehavior setting -- immediate or deferred (like Signal:FireBindable).

Defaults to "bindable". Set via ServerReplicator.SetListenerFireMode/ ClientReplicator.SetListenerFireMode.

SearchCondition

type SearchCondition = string | ReplicationToken | Tags | (replicatorServerReplicator | ClientReplicator) → boolean

A condition used to filter replicators in ForEach/OnNew/GetFirst/etc.

  • string: matches a replicator whose Namespace equals the string.
  • ReplicationToken: matches a replicator whose Namespace equals the token's name.
  • Tags: matches a replicator whose tags are a superset of the given tags.
  • function: a custom predicate.

Anonymous replicators (no Namespace) never match a string or token condition but are reachable via tags, GetFromId, ForEach(predicate), and ReplicatorCreated.

Properties

Client

This item only works when running on the client. Client
TableReplicator.Client: ClientReplicator

Server

This item only works when running on the server. Server
TableReplicator.Server: ServerReplicator
Show raw api
{
    "functions": [],
    "properties": [
        {
            "name": "Client",
            "desc": "\t",
            "lua_type": "ClientReplicator",
            "realm": [
                "Client"
            ],
            "source": {
                "line": 87,
                "path": "lib/tablereplicator/src/init.luau"
            }
        },
        {
            "name": "Server",
            "desc": "\t",
            "lua_type": "ServerReplicator",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 94,
                "path": "lib/tablereplicator/src/init.luau"
            }
        }
    ],
    "types": [
        {
            "name": "ReplicationToken",
            "desc": "An optional, opt-in handle that exclusively owns a namespace name for its\nlifetime. Tokens are created with `ServerReplicator.TOKEN(\"MyToken\")` and\nenforce collision safety: no other token or raw-string replicator may claim\nthe same name while this token is alive.\n\nTokens are optional — a `Namespace` can be a plain `string` without a token.\nUse `TOKEN()` only when you need the collision guard.\n\nTo release ownership, call `ServerReplicator.TOKEN.destroy(token)` after all\nreplicators using this namespace have been destroyed.",
            "lua_type": "{ Name: string }",
            "source": {
                "line": 42,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "ReplicationTargets",
            "desc": "The Player(s) that a top-level replicator should replicate to.\n`\"all\"` replicates to all current and future players.",
            "lua_type": "\"all\" | Player | {Player}",
            "source": {
                "line": 49,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "FireMode",
            "desc": "Controls how discovery listeners (`ReplicatorCreated`, `ForEach`, `OnNew`)\nare scheduled when a matching replicator is found:\n- `\"immediate\"`: runs right away, on a new thread (like `Signal:Fire`).\n- `\"deferred\"`: runs at the end of the resumption cycle (like `Signal:FireDeferred`).\n- `\"bindable\"`: mirrors `BindableEvent` behavior for the current\n  `Workspace.SignalBehavior` setting -- immediate or deferred (like `Signal:FireBindable`).\n\nDefaults to `\"bindable\"`. Set via `ServerReplicator.SetListenerFireMode`/\n`ClientReplicator.SetListenerFireMode`.",
            "lua_type": "\"immediate\" | \"deferred\" | \"bindable\"",
            "source": {
                "line": 63,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "SearchCondition",
            "desc": "A condition used to filter replicators in `ForEach`/`OnNew`/`GetFirst`/etc.\n- `string`: matches a replicator whose `Namespace` equals the string.\n- `ReplicationToken`: matches a replicator whose `Namespace` equals the token's name.\n- `Tags`: matches a replicator whose tags are a superset of the given tags.\n- `function`: a custom predicate.\n\nAnonymous replicators (no `Namespace`) never match a string or token condition\nbut are reachable via tags, `GetFromId`, `ForEach(predicate)`, and `ReplicatorCreated`.",
            "lua_type": "string | ReplicationToken | Tags | (replicator: ServerReplicator | ClientReplicator) -> boolean",
            "source": {
                "line": 76,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        }
    ],
    "name": "TableReplicator",
    "desc": "Replicates `TableManager` instances from the server to clients. A\n`ServerReplicator` wraps a `TableManager`, decides which players can see it,\nand mirrors every write to a matching `ClientReplicator` on each targeted client.\n\nAccess the API through `TableReplicator.Server` (server) or\n`TableReplicator.Client` (client).\n\n**Server**\n```lua\nlocal ServerReplicator = require(Packages.TableReplicator).Server\n\nPlayers.PlayerAdded:Connect(function(player)\n\tlocal replicator = ServerReplicator.new({\n\t\tNamespace = \"PlayerData\",\n\t\tData = { Coins = 0 },\n\t\tReplicationTargets = player,\n\t})\n\n\treplicator.Manager:Set(\"Coins\", 100) -- automatically replicated\n\n\tplayer.Destroying:Connect(function()\n\t\treplicator:Destroy()\n\tend)\nend)\n```\n\n**Client**\n```lua\nlocal ClientReplicator = require(Packages.TableReplicator).Client\n\n-- Register listeners before requesting data to catch replicators in the snapshot.\nClientReplicator.ForEach(\"PlayerData\", function(replicator)\n\treplicator.Manager:Observe(\"Coins\", function(coins)\n\t\tprint(\"Coins:\", coins)\n\tend)\nend)\n\nClientReplicator.RequestData()\n```\n---\n### Exported Types\n- ServerReplicator\n- ClientReplicator\n- BaseReplicator\n- Replicator\n- ReplicationToken\n- ReplicationTargets\n- SearchCondition\n- Tags\n- FireMode",
    "source": {
        "line": 57,
        "path": "lib/tablereplicator/src/init.luau"
    }
}