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. YieldsRetrieves 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.