How would I send information using a RemoteEvent?

Hello, I am trying to send two pieces of information through a local script then to a script in server scrpit service using a RemoveEvent. How would I do this. The information I want to send is in the local script. I have a string value and a player.
This is the line in the local script in startergui.

guiEvents.TeamChange:FireServer(plr, selectedTeam)

plr is the local player and selectedTeam is the brickcolor that the player selected in the gui, it’s for a team changer.
Here is the line in the server script.

guiEvents.TeamChange.OnServerEvent:Connect(function(plr, selectedTeam)
print(selectedTeam)
plr.TeamColor = selectedTeam
end)

When I did print(selectedTeam), it printed my username.
When I did plr.TeamColor = selectedTeam, it didn’t even change my team.
What did I do wrong?

1 Like

The LocalPlayer is automatically sent through the event, you just need to pass the selected team:

guiEvents.TeamChange:FireServer(selectedTeam)
guiEvents.TeamChange.OnServerEvent:Connect(function(plr, selectedTeam)
    print(selectedTeam)
    plr.TeamColor = selectedTeam
end)
3 Likes

Oh, I didn’t know that. Thanks for telling me. Also, how would I be able to access the player then?
It has a red line under it now.
image

1 Like

Sorry, I did it inverted. You should instead do:

guiEvents.TeamChange:FireServer(selectedTeam)
guiEvents.TeamChange.OnServerEvent:Connect(function(plr, selectedTeam)
    print(selectedTeam)
    plr.TeamColor = selectedTeam
end)
3 Likes

whene player fire even the first value are the player that sent info you have to add (plr,selecteam)

2 Likes

Thank you so much! It worked. ㅤㅤ

1 Like