I have this script, and inside it there is a RemoteEvent. I was wondering if there was a way it could be multi purposed? So if you fire it, It would be like this
game.ServerScriptService.Script.RemoteEvent:FireServer("Event")
And then you could fire the same remote but with something else like this
game.ServerScriptService.Script.RemoteEvent:FireServer("EventSameScript")
But if you can, how would you detect these?
Thanks
If you wanted, you could have one RemoteEvent that listens for a hypothetical PacketId
. When you Fire the remote event, you would send a PacketId
as your first argument and then the rest of the data. Here's an example.
On the server it would look something like this:
game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(player, packetId, ...) if packetId == 1 then -- Do somthing elseif packetId == 2 then -- Do another thing end end)
Obviously, you don't have to handle all the packetId's on the same script.
Then on the Localscript
you would do this:
game.ReplicatedStorage.Remote:FireServer(1, stuff, moreStuff) -- OR YOU COULD DO game.ReplicatedStorage.Remote:FireServer(2, stuff, moreStuff)
If you liked this post, please upvote and accept. I'm tryin to get that rep.