Skip to main content

ReplicaServer

This item only works when running on the server. ServerReplica

A class for creating replicated objects.

All state keys must be strings.

Functions

getReplicasByClass

ReplicaServer.getReplicasByClass(
classstring--

The class of the ReplicaServer objects

) → {ReplicaServer}

Get all ReplicaServer objects by their class

getReplicaById

ReplicaServer.getReplicaById(
replicaIdstring--

The replicaId of the ReplicaServer object

) → ReplicaServer?

Get a ReplicaServer object by its replicaId

new

ReplicaServer.new(
configReplicaServerConfig--

Configuration for the replicated object

) → ReplicaServer--

The new ReplicaServer object

Types

interface ReplicaServerConfig {
players{Player}?--

If defined, only these players will receive the replicated object

initialState{[string]any}?--

The initial state of the replicated object. Keys must be strings.

classstring--

The class of the replicated object

}

Create a new ReplicaServer object

Fire

ReplicaServer:Fire(
actionReplicaTypes.Action--

The action to fire

) → ()

Fires an action to the appropriate clients

Push

ReplicaServer:Push(
keystring--

The key to push

) → ()

Pushes the changed key to the clients

Set

ReplicaServer:Set(
keystring,--

The key to REPLICA_UPDATE

valueany--

The value to set

) → ()

Sets the value of a key in the ReplicaServer object and pushes the change to the clients

Destroy

Cleanup
ReplicaServer:Destroy() → ()

Destroys a replica object and replicates the event to clients

Show raw api
{
    "functions": [
        {
            "name": "getReplicasByClass",
            "desc": "Get all ReplicaServer objects by their class",
            "params": [
                {
                    "name": "class",
                    "desc": "The class of the ReplicaServer objects",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ReplicaServer }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 67,
                "path": "src/Replica/ReplicaServer.luau"
            }
        },
        {
            "name": "getReplicaById",
            "desc": "Get a ReplicaServer object by its replicaId",
            "params": [
                {
                    "name": "replicaId",
                    "desc": "The replicaId of the ReplicaServer object",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ReplicaServer?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 85,
                "path": "src/Replica/ReplicaServer.luau"
            }
        },
        {
            "name": "new",
            "desc": "Create a new ReplicaServer object",
            "params": [
                {
                    "name": "config",
                    "desc": "Configuration for the replicated object",
                    "lua_type": "ReplicaServerConfig"
                }
            ],
            "returns": [
                {
                    "desc": "The new ReplicaServer object",
                    "lua_type": "ReplicaServer"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 101,
                "path": "src/Replica/ReplicaServer.luau"
            }
        },
        {
            "name": "Fire",
            "desc": "Fires an action to the appropriate clients",
            "params": [
                {
                    "name": "action",
                    "desc": "The action to fire",
                    "lua_type": "ReplicaTypes.Action"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 154,
                "path": "src/Replica/ReplicaServer.luau"
            }
        },
        {
            "name": "Push",
            "desc": "Pushes the changed key to the clients",
            "params": [
                {
                    "name": "key",
                    "desc": "The key to push",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 171,
                "path": "src/Replica/ReplicaServer.luau"
            }
        },
        {
            "name": "Set",
            "desc": "Sets the value of a key in the ReplicaServer object and pushes the change to the clients",
            "params": [
                {
                    "name": "key",
                    "desc": "The key to REPLICA_UPDATE",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "The value to set",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 191,
                "path": "src/Replica/ReplicaServer.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Destroys a replica object and replicates the event to clients",
            "params": [],
            "returns": [],
            "function_type": "method",
            "tags": [
                "Cleanup"
            ],
            "source": {
                "line": 204,
                "path": "src/Replica/ReplicaServer.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "ReplicaServerConfig",
            "desc": "",
            "fields": [
                {
                    "name": "players",
                    "lua_type": "{ Player }?",
                    "desc": "If defined, only these players will receive the replicated object"
                },
                {
                    "name": "initialState",
                    "lua_type": "{ [string]: any }?",
                    "desc": "The initial state of the replicated object. Keys must be strings."
                },
                {
                    "name": "class",
                    "lua_type": "string",
                    "desc": "The class of the replicated object"
                }
            ],
            "source": {
                "line": 48,
                "path": "src/Replica/ReplicaServer.luau"
            }
        }
    ],
    "name": "ReplicaServer",
    "desc": "A class for creating replicated objects.\n\nAll state keys must be strings.",
    "tags": [
        "Replica"
    ],
    "realm": [
        "Server"
    ],
    "source": {
        "line": 10,
        "path": "src/Replica/ReplicaServer.luau"
    }
}