GetRemoteFunction
Provides getting named global RemoteFunction resources.
Functions
GetRemoteFunction
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 function from the store. On the server, it constructs a new one, and on the client, it waits for it to exist.
tip
Consider using PromiseGetRemoteFunction for a non-yielding version
-- server.lua
local GetRemoteFunction = require("GetRemoteFunction")
local remoteFunction = GetRemoteFunction("testing")
remoteFunction.OnServerInvoke = function(_player, text)
return "HI " .. tostring(text)
end
-- client.lua
local GetRemoteFunction = require("GetRemoteFunction")
local remoteFunction = GetRemoteFunction("testing")
print(remoteFunction:InvokeServer("Bob")) --> HI Bob
info
If the game is not running, then a mock remote function will be created for use in testing.