I've been trying to communicate between Clients and Servers via RemoteEvent. However, when I try to make a "function (remoteEvent Name).OnServerEvent()", there is an error saying "OnServerEvent is not a valid member of RemoteEvent". Please help, here is the code.
In the Client Script:
-- all of this is previously defined folder:WaitForChild("MG"):FireServer(plr, "on")
In the Server Script:
function folder.Reload.OnServerEvent(onOrOff) -- code end
As eLunate said, OnServerEvent
is an Event
, not a callback
. Saying something like:
function Remote.OnServerEvent(...) end
Is the same as saying:
Remote.OnServerEvent = function(...) end
You must use the connect
method that binds your function
to the event
. Take this example:
-- "Client" is automatically defined as the player of the local script who called the function. The first argument of this event will ALWAYS be the local player. Remote.OnServerEvent:connect(function(Client,...) end)