RemoteEvent Handler

You can use just one RemoteEvent or RemoteFunction to handle many different calls instead of registering a whole new one for every single little message you want to send across the wire. My idiom usually looks something like this:

server

local remoteHandler = {}

function remoteHandler.doOneThing( player, data1 )

 ...

end

function remoteHandler.doAnotherThing( player, data1, data2 )

 ...

end

workspace.Signals.RemoteHandler.OnServerEvent:Connect( function( player, funcname, … )

 assert( remoteHandler[ funcname ] )

 remoteHandler[funcname]( … )

end

client

workspace.Signals.RemoteHandler:FireServerEvent( "doOneThing", data )

你可能感兴趣的:(RemoteEvent Handler)