Skip to main content

GetRemote

Provides a simple interface for creating and using remotes. The Remote object is a wrapper that will dynamically create RemoteEvents, UnreliableRemoteEvents, and RemoteFunctions based on how it is used, combining the interface of all three into one for ease of use.

local GetRemote = shared("GetRemote") ---@module GetRemote

local TestRemote = GetRemote("TestRemote")

TestRemote:OnEvent(function(player, ...)
	print("TestRemote fired by " .. player.Name .. ", got:", ...)
end)

TestRemote:OnInvoke(function()
	return "Working"
end)

TestRemote:Fire("Fired to all clients")

local player = Players:GetPlayers()[1]
print("Client invoke test returned:", TestRemote:Invoke(player))
TestRemote:FireClient(player, "Fired to " .. player.Name)

Functions

GetRemote

GetRemote.GetRemote(
namestring,--

The name of the remote

forceLoadRemoteForceLoad?--

Optionally pre-create specific underlying remote instances

) → Remote

Returns a Remote object for the given name, creating it if it does not already exist. The same object is returned for repeated calls with the same name.

Show raw api
{
    "functions": [
        {
            "name": "GetRemote",
            "desc": "Returns a [Remote](/api/Remote) object for the given name, creating it if it does not\nalready exist. The same object is returned for repeated calls with the same\nname.",
            "params": [
                {
                    "name": "name",
                    "desc": "The name of the remote",
                    "lua_type": "string"
                },
                {
                    "name": "forceLoad",
                    "desc": "Optionally pre-create specific underlying remote instances",
                    "lua_type": "RemoteForceLoad?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Remote"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 717,
                "path": "src/shared/core/lib/GetRemote.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "GetRemote",
    "desc": "Provides a simple interface for creating and using remotes. The [Remote](/api/Remote)\nobject is a wrapper that will dynamically create `RemoteEvents`,\n`UnreliableRemoteEvents`, and `RemoteFunctions` based on how it is used,\ncombining the interface of all three into one for ease of use.\n\n```lua\nlocal GetRemote = shared(\"GetRemote\") ---@module GetRemote\n\nlocal TestRemote = GetRemote(\"TestRemote\")\n\nTestRemote:OnEvent(function(player, ...)\n\tprint(\"TestRemote fired by \" .. player.Name .. \", got:\", ...)\nend)\n\nTestRemote:OnInvoke(function()\n\treturn \"Working\"\nend)\n\nTestRemote:Fire(\"Fired to all clients\")\n\nlocal player = Players:GetPlayers()[1]\nprint(\"Client invoke test returned:\", TestRemote:Invoke(player))\nTestRemote:FireClient(player, \"Fired to \" .. player.Name)\n```",
    "source": {
        "line": 37,
        "path": "src/shared/core/lib/GetRemote.luau"
    }
}