Skip to main content

ClientReplicator

This item only works when running on the client. Client

The client-side mirror of a ServerReplicator. Construction is entirely server-driven — clients never create or destroy replicators directly.

Call RequestData() once to request the initial snapshot and begin live replication. Register ForEach/OnNew listeners before calling it so they receive replicators from the initial snapshot too.

local ClientReplicator = require(Packages.TableReplicator).Client

ClientReplicator.ForEach("PlayerData", function(replicator)
	replicator.Manager:Observe("Coins", function(coins)
		print("Coins:", coins)
	end)
end)

ClientReplicator.RequestData():andThen(function()
	print("initial snapshot applied")
end)

Access replicated data through the .Manager property. To listen to server-fired custom signals, use the .Server proxy: replicator.Server.MySignal:Connect(fn).

Properties

ReplicatorCreated

Static
ClientReplicator.ReplicatorCreated: Signal<ClientReplicator>

Signal that fires whenever a new replicator is created, regardless of token.

Id

This item is read only and cannot be modified. Read Only
ClientReplicator.Id: number

The unique Id of this replicator.

Manager

This item is read only and cannot be modified. Read Only
ClientReplicator.Manager: TableManager

The TableManager that this replicator is managing.

Namespace

This item is read only and cannot be modified. Read Only
ClientReplicator.Namespace: string?

The namespace string of this replicator, or nil if anonymous.

Token

This item is read only and cannot be modified. Read Only
ClientReplicator.Token: ReplicationToken?

The token handle for this replicator, or nil if anonymous.

Tags

This item is read only and cannot be modified. Read Only
ClientReplicator.Tags: {[string]any}

The tags of this replicator.

ChildAdded

Event
ClientReplicator.ChildAdded: Signal<ClientReplicator>

Fired when a child replicator is added to this replicator.

ChildRemoved

Event
ClientReplicator.ChildRemoved: Signal<ClientReplicator>

Fired when a child replicator is removed from this replicator.

ParentChanged

Event
ClientReplicator.ParentChanged: Signal<ClientReplicator,ClientReplicator>

Fired when this replicator's parent is changed. Passed arguments are (newParent, oldParent).

Functions

SetListenerFireMode

Static
ClientReplicator.SetListenerFireMode(modeFireMode) → ()

Overrides ListenerFireMode, the scheduling used for ReplicatorCreated, ForEach, and OnNew listeners going forward.

GetFromId

Static
ClientReplicator.GetFromId(idId) → ClientReplicator?

Returns the replicator with the given Id, if one currently exists.

PromiseFromId

Static
ClientReplicator.PromiseFromId(idId) → Promise<ClientReplicator>

Returns a promise that resolves with the replicator with the given Id, if one currently exists or is created in the future.

GetAll

Static
ClientReplicator.GetAll(conditionSearchCondition?) → {ClientReplicator}

Returns every currently-loaded replicator matching condition (no condition = all).

ForEach

Static
ClientReplicator.ForEach(
conditionSearchCondition?,
fn(replicatorClientReplicator) → ()
) → () → ()

Runs fn for every existing replicator matching condition, and again for every future one. Returns a disconnect function that stops future invocations.

-- By namespace string:
local disconnect = ClientReplicator.ForEach("PlayerData", function(replicator)
	replicator.Manager:Observe("Coins", function(coins)
		print("Coins:", coins)
	end)
end)

-- By tag predicate:
ClientReplicator.ForEach({ UserId = localPlayer.UserId }, function(replicator)
	-- only fires for the local player's replicator
end)

PromiseFirst

Static
ClientReplicator.PromiseFirst(conditionSearchCondition?) → Promise<ClientReplicator>

Resolves with the first existing-or-future replicator matching condition.

ClientReplicator.PromiseFirst("PlayerData"):andThen(function(replicator)
	print("Got PlayerData replicator:", replicator.Id)
end)

GetFirst

Static
ClientReplicator.GetFirst(conditionSearchCondition?) → ClientReplicator?

Returns the first replicator matching condition, or nil if none exists.

OnNew

Static
ClientReplicator.OnNew(
conditionSearchCondition,
fn(replicatorClientReplicator) → ()
) → () → ()

Listens for new replicators matching condition. Returns a disconnect function.

Prefer ForEach

OnNew only fires for replicators created after this call. Call ForEach to handle any already-existing matches too. If called after RequestData has resolved, any replicators in the initial snapshot will be missed.

RequestData

Static
ClientReplicator.RequestData() → Promise<()>

Requests the initial snapshot from the server and begins live replication. Returns a Promise that resolves once the server confirms the full snapshot has been sent. Safe to call more than once (subsequent calls are no-ops).

Register ForEach/OnNew listeners before calling this so they receive replicators from the initial snapshot.

IsTopLevel

ClientReplicator:IsTopLevel() → boolean

Returns true if this replicator has no parent.

GetParent

ClientReplicator:GetParent() → ClientReplicator?

Gets the parent replicator, or nil if this is a top-level replicator.

GetChildren

ClientReplicator:GetChildren() → {ClientReplicator}

Gets the immediate children of this replicator.

GetDescendants

ClientReplicator:GetDescendants() → {ClientReplicator}

Gets all descendants of this replicator, recursively.

FindFirstChild

ClientReplicator:FindFirstChild(
conditionSearchCondition?,--

optional predicate, token name, or tag set

recursiveboolean?--

whether to search recursively (default false)

) → ClientReplicator?

Finds the first child of this replicator that matches condition, or nil if none.

PromiseFirstChild

ClientReplicator:PromiseFirstChild(conditionSearchCondition?) → Promise<ClientReplicator>

Returns a Promise that resolves with the first child matching condition. Resolves immediately if a matching child already exists; otherwise waits for one to be added.

HasTags

ClientReplicator:HasTags(tagsTags) → boolean

Returns true if every key/value in tags is present on this replicator. IsSupersetOfTags is an alias for this method.

IsSupersetOfTags

ClientReplicator:IsSupersetOfTags(tagsTags) → boolean

Alias for HasTags.

IsSubsetOfTags

ClientReplicator:IsSubsetOfTags(tagsTags) → boolean

Returns true if every key/value on this replicator is present in tags. The inverse of HasTags: this replicator's tags must be a subset of tags.

Show raw api
{
    "functions": [
        {
            "name": "SetListenerFireMode",
            "desc": "Overrides `ListenerFireMode`, the scheduling used for `ReplicatorCreated`,\n`ForEach`, and `OnNew` listeners going forward.",
            "params": [
                {
                    "name": "mode",
                    "desc": "",
                    "lua_type": "FireMode"
                }
            ],
            "returns": [],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 174,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "GetFromId",
            "desc": "Returns the replicator with the given Id, if one currently exists.",
            "params": [
                {
                    "name": "id",
                    "desc": "",
                    "lua_type": "Id"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ClientReplicator?"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 223,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "PromiseFromId",
            "desc": "Returns a promise that resolves with the replicator with the given Id, if one currently exists or is created in the future.",
            "params": [
                {
                    "name": "id",
                    "desc": "",
                    "lua_type": "Id"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<ClientReplicator>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 243,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "GetAll",
            "desc": "Returns every currently-loaded replicator matching `condition` (no condition = all).",
            "params": [
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "SearchCondition?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ClientReplicator }"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 272,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "ForEach",
            "desc": "Runs `fn` for every existing replicator matching `condition`, and again for\nevery future one. Returns a disconnect function that stops future invocations.\n\n```lua\n-- By namespace string:\nlocal disconnect = ClientReplicator.ForEach(\"PlayerData\", function(replicator)\n\treplicator.Manager:Observe(\"Coins\", function(coins)\n\t\tprint(\"Coins:\", coins)\n\tend)\nend)\n\n-- By tag predicate:\nClientReplicator.ForEach({ UserId = localPlayer.UserId }, function(replicator)\n\t-- only fires for the local player's replicator\nend)\n```",
            "params": [
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "SearchCondition?"
                },
                {
                    "name": "fn",
                    "desc": "",
                    "lua_type": "(replicator: ClientReplicator) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "() -> ()"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 327,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "PromiseFirst",
            "desc": "Resolves with the first existing-or-future replicator matching `condition`.\n\n```lua\nClientReplicator.PromiseFirst(\"PlayerData\"):andThen(function(replicator)\n\tprint(\"Got PlayerData replicator:\", replicator.Id)\nend)\n```",
            "params": [
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "SearchCondition?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<ClientReplicator>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 370,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "GetFirst",
            "desc": "Returns the first replicator matching `condition`, or nil if none exists.",
            "params": [
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "SearchCondition?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ClientReplicator?"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 396,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "OnNew",
            "desc": "Listens for *new* replicators matching `condition`. Returns a disconnect function.\n\n:::caution Prefer ForEach\n`OnNew` only fires for replicators created **after** this call. Call `ForEach`\nto handle any already-existing matches too. If called after `RequestData` has\nresolved, any replicators in the initial snapshot will be missed.\n:::",
            "params": [
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "SearchCondition"
                },
                {
                    "name": "fn",
                    "desc": "",
                    "lua_type": "(replicator: ClientReplicator) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "() -> ()"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 438,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "IsTopLevel",
            "desc": "Returns true if this replicator has no parent.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 609,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "GetParent",
            "desc": "Gets the parent replicator, or nil if this is a top-level replicator.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ClientReplicator?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 629,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "GetChildren",
            "desc": "Gets the immediate children of this replicator.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ClientReplicator }"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 645,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "GetDescendants",
            "desc": "Gets all descendants of this replicator, recursively.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ClientReplicator }"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 661,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "FindFirstChild",
            "desc": "Finds the first child of this replicator that matches `condition`, or nil if none.",
            "params": [
                {
                    "name": "condition",
                    "desc": "optional predicate, token name, or tag set",
                    "lua_type": "SearchCondition?"
                },
                {
                    "name": "recursive",
                    "desc": "whether to search recursively (default false)",
                    "lua_type": "boolean?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ClientReplicator?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 689,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "PromiseFirstChild",
            "desc": "Returns a Promise that resolves with the first child matching `condition`.\nResolves immediately if a matching child already exists; otherwise waits for\none to be added.",
            "params": [
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "SearchCondition?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<ClientReplicator>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 732,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "HasTags",
            "desc": "Returns true if every key/value in `tags` is present on this replicator.\n`IsSupersetOfTags` is an alias for this method.",
            "params": [
                {
                    "name": "tags",
                    "desc": "",
                    "lua_type": "Tags"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 765,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "IsSupersetOfTags",
            "desc": "Alias for `HasTags`.",
            "params": [
                {
                    "name": "tags",
                    "desc": "",
                    "lua_type": "Tags"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 788,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "IsSubsetOfTags",
            "desc": "Returns true if every key/value on this replicator is present in `tags`.\nThe inverse of `HasTags`: this replicator's tags must be a subset of `tags`.",
            "params": [
                {
                    "name": "tags",
                    "desc": "",
                    "lua_type": "Tags"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 806,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "ClientReplicators are torn down by the server, never by local code. Calling\nthis method directly raises an error.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "ignore": true,
            "source": {
                "line": 238,
                "path": "lib/tablereplicator/src/Client/ClientReplicator.luau"
            }
        },
        {
            "name": "RequestData",
            "desc": "Requests the initial snapshot from the server and begins live replication.\nReturns a Promise that resolves once the server confirms the full snapshot\nhas been sent. Safe to call more than once (subsequent calls are no-ops).\n\nRegister `ForEach`/`OnNew` listeners **before** calling this so they receive\nreplicators from the initial snapshot.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<()>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 281,
                "path": "lib/tablereplicator/src/Client/ClientReplicator.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "ReplicatorCreated",
            "desc": "Signal that fires whenever a new replicator is created, regardless of token.",
            "lua_type": "Signal<ClientReplicator>",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 147,
                "path": "lib/tablereplicator/src/Shared/BaseReplicator.luau"
            }
        },
        {
            "name": "Id",
            "desc": "The unique Id of this replicator.",
            "lua_type": "number",
            "readonly": true,
            "source": {
                "line": 227,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "Manager",
            "desc": "The TableManager that this replicator is managing.",
            "lua_type": "TableManager",
            "readonly": true,
            "source": {
                "line": 237,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "Namespace",
            "desc": "The namespace string of this replicator, or `nil` if anonymous.",
            "lua_type": "string?",
            "readonly": true,
            "source": {
                "line": 248,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "Token",
            "desc": "The token handle for this replicator, or `nil` if anonymous.",
            "lua_type": "ReplicationToken?",
            "readonly": true,
            "source": {
                "line": 261,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "Tags",
            "desc": "The tags of this replicator.",
            "lua_type": "{ [string]: any }",
            "readonly": true,
            "source": {
                "line": 271,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "ChildAdded",
            "desc": "Fired when a child replicator is added to this replicator.",
            "lua_type": "Signal<ClientReplicator>",
            "tags": [
                "Event"
            ],
            "source": {
                "line": 282,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "ChildRemoved",
            "desc": "Fired when a child replicator is removed from this replicator.",
            "lua_type": "Signal<ClientReplicator>",
            "tags": [
                "Event"
            ],
            "source": {
                "line": 292,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        },
        {
            "name": "ParentChanged",
            "desc": "Fired when this replicator's parent is changed.\nPassed arguments are `(newParent, oldParent)`.",
            "lua_type": "Signal<ClientReplicator, ClientReplicator>",
            "tags": [
                "Event"
            ],
            "source": {
                "line": 304,
                "path": "lib/tablereplicator/src/Shared/Types.luau"
            }
        }
    ],
    "types": [],
    "name": "ClientReplicator",
    "desc": "The client-side mirror of a `ServerReplicator`. Construction is entirely\nserver-driven — clients never create or destroy replicators directly.\n\nCall `RequestData()` once to request the initial snapshot and begin live\nreplication. Register `ForEach`/`OnNew` listeners **before** calling it so\nthey receive replicators from the initial snapshot too.\n\n```lua\nlocal ClientReplicator = require(Packages.TableReplicator).Client\n\nClientReplicator.ForEach(\"PlayerData\", function(replicator)\n\treplicator.Manager:Observe(\"Coins\", function(coins)\n\t\tprint(\"Coins:\", coins)\n\tend)\nend)\n\nClientReplicator.RequestData():andThen(function()\n\tprint(\"initial snapshot applied\")\nend)\n```\n\nAccess replicated data through the `.Manager` property. To listen to server-fired\ncustom signals, use the `.Server` proxy: `replicator.Server.MySignal:Connect(fn)`.",
    "realm": [
        "Client"
    ],
    "source": {
        "line": 30,
        "path": "lib/tablereplicator/src/Client/ClientReplicator.luau"
    }
}