Remote Event name sender without including it inside of the FireServer()?

So I was working on a script that involves a RemoteEvent. I know to put an extra argument before the 2nd and 3rd arguments. I know that the 1st argument prints the player’s name, but my question is why does it print the name of the player when I never sent over the player in the local script being used to fire the server.


local RS = game:GetService("ReplicatedStorage")

local TeamNameRE = RS:WaitForChild("Teams"):WaitForChild("TeamNames")

local WS = game:GetService("Workspace")

--Declarations--

local LeftTeamNameTL = WS.LeftTeam.TeamNameBar.TeamName.SurfaceGui.TextLabel

local RightTeamNameTL = WS.RightTeam.TeamNameBar.TeamName.SurfaceGui.TextLabel

TeamNameRE.OnServerEvent:Connect(function(plr, team1Name, team2Name)

print(plr, team1Name, team2Name)

end)

Can anyone explain to my why it prints the plr name when I never fired that information to this script? I only sent this info to the server. This is the local script:

EnterButton.Activated:Connect(function()
	TeamNameRE:FireServer(Team1TB.Text, Team2TB.Text)
	RS:WaitForChild("DestroyGUI"):FireServer(plr.Name, ScreenGUI.Name)
	ScreenGUI:Destroy()
end)

I know that it does it, but I don’t understand the reasoning of why it sends the player’s name to the server script instead of only the 2 things I included into the parenthesis on line 2. If you could, that would be helpful, thanks! :smile:

This is done implicitly by Roblox so you know who fired it.

4 Likes

When firing a remote to the server from the client, you don’t need to pass the player as the 1st argument, or at all, because Roblox does this for you automatically as @sjr04 stated.

According to the API, the player parameter is already given, so you don’t have to fire the player’s information because it tells you WHO exactly fired the event to the server.

Anything else inside of the parenthesis that you input are the arguments. So if you put 2 parameters inside of the :FireServer(), you will have 3 parameters inside of the .OnServerEvent

Here’s the API: RemoteEvent | Documentation - Roblox Creator Hub

1 Like