So lets suppose i have a local script on player local scripts, and it Fires a remote event script, how can the server side script determine what player invoked it?
LocalScript : local RemoteEvent = --Location of the same RemoteEvent local Data1 = 123 local Data2 = abc local Data3 = true RemoteEvent:FireServer(Data1, Data2, Data3)
Server Script :
local RemoteEvent = --Location of the RemoteEvent local function OnServerEvent (Player, Data1, Data2, Data3) --etc print(Player.Name) --> CjayPlyz print(Data1) --> 123 print(Data2) --> abc print(Data3) --> true end
If you don't put Player in the ()
then Data1
would be the variable for the Player.
The player that called the server is actually passed as an argument to the server remote event handler; for example
-- server script
remote.OnServerEvent:Connect(function(player) --handler code goes here print(player.Name) --etc end