Classes
RemoteEventService
RemoteEventService
is used for communicating between client and server, and vise-versa
You cannot Instance this class with
Instance.new()
Functions
PushToClient(string username, string eventName, ...)
This function can only be called by the server.
local RemoteEventService = Game:GetService("RemoteEventService")
local error = RemoteEventService:PushToClient("Cubern", "Event1", "hello!", Map.Cube, 22233)
if error == nil then
printl("It is a success!")
else
printl("It failed! The error is: " .. error)
end
PushToAllClients(string eventName, ...)
This function can only be called by the server.
local RemoteEventService = Game:GetService("RemoteEventService")
local error = RemoteEventService:PushToAllClients("Event1", "Starting minigame!")
if error == nil then
printl("It is a success!")
else
printl("It failed! The error is: " .. error)
end
SendEventToServer(string eventName, ...)
This function can only be called by the client.
ConnectEvent(string eventName, ...)
This function can be called by both the client and the server.
eventName
is fired by the server or the client: the connected function will be called. An example:
local RemoteEventService = Game:GetService("RemoteEventService")
RemoteEventService:ConnectEvent("Event1", __SCRIPT__, "FunctionCall") -- since we had registered the event by name of "Event1" we will use "Event1" as first paramter
-- Same way can be used for the server
function FunctionToCall(data)
printl(data.CastleName)
end