I am trying to sort players into teams on their own decision. It works but doesn't change their team in the leaderboard. This is my script for my team selector how do I change the player's leaderboard team?
wait(0.2); script.Parent.RebelsButton.MouseButton1Click:connect(function() game.Players.LocalPlayer.TeamColor = game.Teams.Rebels.TeamColor; game.Players.LocalPlayer:LoadCharacter(); game.Players.LocalPlayer.PlayerGui.TeamSelectGui:Destroy(); game.Workspace.Humanoid.name.TeamColor = "Really red" end)
script.Parent.SoldierButton.MouseButton1Click:connect(function() game.Players.LocalPlayer.TeamColor = game.Teams.Soldiers.TeamColor; game.Players.LocalPlayer:LoadCharacter(); game.Players.LocalPlayer.PlayerGui.TeamSelectGui:Destroy(); game.Workspace.Humanoid.name.TeamColor = "Dark blue" end)
Well, the problem is, you can't use LocalPlayer on a Script.
LocalPlayer is only usable in LocalScripts.
Basically, the script runs, but does not know which is the player it has to team.
There is no way for a ClickDetector to know who is clicking.
You should use a LocalScript that knows when a player clicks that button, etc.
This is all in LocalScript
script.Parent.RebelsButton.MouseButton1Click:connect(function() local plr = game.Players.LocalPlayer plr:WaitForChild("TeamColor").Value = game:GetService("Teams").Rebels.TeamColor plr:LoadCharacter() plr:WaitForChild("PlayerGui").TeamSelectGui:Destroy(); -- game.Workspace.Humanoid.name.TeamColor = "Really red" end) [What are you doing exactly here?] script.Parent.SoldierButton.MouseButton1Click:connect(function() local plr = game.Players.LocalPlayer plr:WaitForChild("TeamColor").Value = game:GetService("Teams").Soldiers.TeamColor plr:LoadCharacter() plr:WaitForChild("PlayerGui").TeamSelectGui:Destroy() -- game.Workspace.Humanoid.name.TeamColor = "Dark blue" end) [And here.]
Hope this kind of helps.