Skip to main content

GetRemoteEvent

Provides getting named global RemoteEvent resources.

Functions

GetRemoteEvent

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
GetRemoteEvent.GetRemoteEvent(namestring) → RemoteEvent

Retrieves a global remote event from the store. On the server, it constructs a new one, and on the client, it waits for it to exist.

tip

Consider using PromiseGetRemoteEvent for a non-yielding version

-- server.lua
local GetRemoteEvent = require("GetRemoteEvent")

local remoteEvent = GetRemoteEvent("testing")
remoteEvent.OnServerEvent:Connect(print)

-- client.lua
local GetRemoteEvent = require("GetRemoteEvent")

local remoteEvent = GetRemoteEvent("testing")
remoteEvent:FireServer("Hello") --> Hello (on the server)
info

If the game is not running, then a mock remote event will be created for use in testing.

Show raw api
{
    "functions": [
        {
            "name": "GetRemoteEvent",
            "desc": "Retrieves a global remote event from the store. On the server, it constructs a new one,\nand on the client, it waits for it to exist.\n\n:::tip\nConsider using [PromiseGetRemoteEvent] for a non-yielding version\n:::\n\n```lua\n-- server.lua\nlocal GetRemoteEvent = require(\"GetRemoteEvent\")\n\nlocal remoteEvent = GetRemoteEvent(\"testing\")\nremoteEvent.OnServerEvent:Connect(print)\n\n-- client.lua\nlocal GetRemoteEvent = require(\"GetRemoteEvent\")\n\nlocal remoteEvent = GetRemoteEvent(\"testing\")\nremoteEvent:FireServer(\"Hello\") --> Hello (on the server)\n```\n\n:::info\nIf the game is not running, then a mock remote event will be created\nfor use in testing.\n:::",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RemoteEvent"
                }
            ],
            "function_type": "static",
            "yields": true,
            "source": {
                "line": 39,
                "path": "src/remoting/src/Shared/GetRemoteEvent.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "GetRemoteEvent",
    "desc": "Provides getting named global [RemoteEvent] resources.",
    "source": {
        "line": 5,
        "path": "src/remoting/src/Shared/GetRemoteEvent.lua"
    }
}