Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to find what client Invoked server?

Asked by 5 years ago

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?

0
there is a built in parameter in OnServerEvent theking48989987 2147 — 5y

2 answers

Log in to vote
1
Answered by
CjayPlyz 643 Moderation Voter
5 years ago
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.

0
This had me to understand a lot more about remote, thanks Igoralexeymarengobr 365 — 5y
Ad
Log in to vote
1
Answered by 5 years ago

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
0
i did not understand that well but thank you anyways :)! Igoralexeymarengobr 365 — 5y

Answer this question