Skip to main content

Replicator

Server-to-client diff-based replication system.

Functions​

new​

This item only works when running on the server. Server
Replicator.new(
identifier: string,
baseData: {[string]: any}
) → ()

Creates a new Replicator instance. Use only on server.

getReplicator​

Replicator.getReplicator(identifier: string) → Replicator?

Gets the Replicator instance with the given identifier. Returns nil if the Replicator instance does not exist.

waitForReplicator​

Replicator.waitForReplicator(
identifier: string,
maxTime: number?
) → Replicator?

Waits for the Replicator instance with the given identifier to be created. Returns nil if the Replicator instance does not exist after the given time.

initClient​

This item only works when running on the client. Client
Replicator.initClient() → ()

Initializes the Replicator system on the client.

initServer​

This item only works when running on the server. Server
Replicator.initServer() → ()

Initializes the Replicator system on the server.

Set​

This item only works when running on the server. Server
Replicator.Set(
self: Replicator,
path: {string},
value: any
) → ()

Sets the value of the Replicator instance at the given path, which replicates to all subscribed players.

Get​

Replicator.Get(self: Replicator) → ()

Gets the current state of the Replicator instance.

Subscribe​

This item only works when running on the server. Server
Replicator.Subscribe(
self: Replicator,
player: Player
) → ()

Subscribes the given player to the Replicator instance.

Unsubscribe​

This item only works when running on the server. Server
Replicator.Unsubscribe(
self: Replicator,
player: Player
) → ()

Unsubscribes the given player from the Replicator instance.

SubscribeAll​

This item only works when running on the server. Server
Replicator.SubscribeAll(self: Replicator) → ()

Subscribes all players to the Replicator instance.

Destroy​

This item only works when running on the server. Server
Replicator.Destroy(self: Replicator) → ()

Destroys the Replicator instance.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new Replicator instance. Use only on server.",
            "params": [
                {
                    "name": "identifier",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "baseData",
                    "desc": "",
                    "lua_type": "{[string]: any}"
                }
            ],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 46,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "getReplicator",
            "desc": "Gets the Replicator instance with the given identifier.\nReturns nil if the Replicator instance does not exist.",
            "params": [
                {
                    "name": "identifier",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Replicator?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 69,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "waitForReplicator",
            "desc": "Waits for the Replicator instance with the given identifier to be created.\nReturns nil if the Replicator instance does not exist after the given time.",
            "params": [
                {
                    "name": "identifier",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "maxTime",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Replicator?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 78,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "initClient",
            "desc": "Initializes the Replicator system on the client.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Client"
            ],
            "source": {
                "line": 98,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "initServer",
            "desc": "Initializes the Replicator system on the server.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 147,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "Set",
            "desc": "Sets the value of the Replicator instance at the given path, which replicates to all subscribed players.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Replicator"
                },
                {
                    "name": "path",
                    "desc": "",
                    "lua_type": "{string}"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 211,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "Get",
            "desc": "Gets the current state of the Replicator instance.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Replicator"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 250,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "Subscribe",
            "desc": "Subscribes the given player to the Replicator instance.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Replicator"
                },
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 260,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "Unsubscribe",
            "desc": "Unsubscribes the given player from the Replicator instance.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Replicator"
                },
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 285,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "SubscribeAll",
            "desc": "Subscribes all players to the Replicator instance.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Replicator"
                }
            ],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 303,
                "path": "src/Packages/Replicator/init.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Destroys the Replicator instance.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Replicator"
                }
            ],
            "returns": [],
            "function_type": "static",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 319,
                "path": "src/Packages/Replicator/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Replicator",
    "desc": "Server-to-client diff-based replication system.",
    "source": {
        "line": 6,
        "path": "src/Packages/Replicator/init.luau"
    }
}