I really don't want to make a bunch of remote events. How would I make the script know where which script fired it?
COMMUNITY QUESTION
How to find which script remote event was fired from?
1 answer
When you fire a remote event, you can put strings, integers or anything in them example:
RemoteEvent:FireServer('hello', 1, true)
And in the script that receives the event, you can do this:
RemoteEvent.OnServerEvent:Connect(function(player, string, integer, bool) --you have to add
--player at the start or it wont work
print(string) --output will be "hello"
print(integer) -- output will be 1
print(bool) --output will be true
end)
With all that, you can do this:
--localscript
RemoteEvent:FireServer('script1')
--script
RemoteEvent.OnServerEvent:Connect(function(player, scriptname)
if scriptname == 'script1' then
print('hello')
end
end)
Note: if you want to do it from the server to the client, you have to first do: FireClient() instead of FireServer() and second, you have to include the player in the FireClient()'s brackets example: FireClient(game.Players.jedistuff2, 'script1')
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You can’t, unless you set the script as an argument.