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.
1 | local player = game.Players.LocalPlayer |
2 |
3 | script.Parent.MouseButton 1 Click:connect( function () |
4 | player.TeamColor = BrickColor.new( "Really black" ) |
5 | player:LoadCharacter() |
6 | script.Parent.Parent.Parent.Enabled = false |
7 | end ) |
Any help would be appreciated, thanks!
01 | -- This is a server script, not a local script |
02 | script.Parent.MouseButton 1 Click:Connect( function () |
03 | for _,p in pairs (game.Players:GetPlayers()) do |
04 | if p.Name = = "DanielCXI" then |
05 | p.TeamColor = BrickColor.new( "Really black" ) |
06 | p:LoadCharacter() |
07 | p.PlayerGui.ScreenGui.Enabled = true |
08 | end |
09 | end |
10 | 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.