I'm using local scripts. It is a team change GUI. All works in studio, but not in a game. In-game it switches me to the selected team, but does not respawn me, or teleport me to the spawn position. The GUI does not disappear after I selected my team. As said before it works flawlessly on studio.
local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() player.TeamColor = BrickColor.new("Really black") player:LoadCharacter() script.Parent.Parent.Parent.Enabled = false end)
Any help would be appreciated, thanks!
-- This is a server script, not a local script script.Parent.MouseButton1Click:Connect(function() for _,p in pairs(game.Players:GetPlayers()) do if p.Name == "DanielCXI" then p.TeamColor = BrickColor.new("Really black") p:LoadCharacter() p.PlayerGui.ScreenGui.Enabled = true end end end)
There were a couple things wrong with your script:
You are using connect(), which is now officially deprecated. Use Connect(). Seriously.
Changing only the LocalPlayer's properties didn't work (obviously), so you had to run a for loop for each player in-game.