#Is it better to use only one remote event for multiple functions?

1 messages · Page 1 of 1 (latest)

merry thistle
#

Hello.
Will there be any difference if we use the same remote event object instead of creating another for different functions? For example:

--Local script:
game.ServerStorage.RemoteEvent:FireServer("Function a")
--Another line:
game.ServerStorage.RemoteEvent:FireServer("Function b")

--Server script:
game.ServerStorage.RemoteEvent.OnServerEvent:Connect(function(player, func)
if func == "Function a" then

elseif func == "Function b" then

end

end)

Or...

--Local script
game.ServerStorage.RemoteEvent0:FireServer()
game.ServerStorage.RemoteEvent1:FireServer()

--Server script
game.ServerStorage.RemoteEvent0.OnServerEvent
game.ServerStorage.RemoteEvent1.OnServerEvent

Which one is better?

hasty finch
#

multiple events

#

in your case at least

merry thistle
hasty finch
#

if your function opcodes were numbers instead of strings then maybe one remote would be better, but since you're not doing that it isn't really worth the hassle or the effort, and even this is usually not worth the effort.

#

as a general tip, don't go around optimizing things if you don't know how to tell for yourself why one is better than the other. usually shouldn't take randos advice like this about it either coz you might get bad advice and go out of your way to do bad practices based on that.