Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI works in studio but not a published game, how would I fix this? It is a team change GUI.

Asked by 6 years ago

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.

1local player = game.Players.LocalPlayer
2 
3script.Parent.MouseButton1Click:connect(function()
4player.TeamColor = BrickColor.new("Really black")
5player:LoadCharacter()
6script.Parent.Parent.Parent.Enabled = false
7end)

Any help would be appreciated, thanks!

0
You should be handling anything that you want to replicate to all the players (anything you want them all to see) in a server script, not local. mattscy 3725 — 6y
0
I have tried doing this with server scripts, but then it completely did not work in the published game. DanielCXI -5 — 6y
0
i edited my answer DeceptiveCaster 3761 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
01-- This is a server script, not a local script
02script.Parent.MouseButton1Click: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
10end)

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.

0
Why not Players:FindFirstChild("DanielCXI") tho Amiaa16 3227 — 6y
0
Or even script.Parent:FindFirstAncestorOfClass("Player") since the gui is parented to someone's PlayerGui Amiaa16 3227 — 6y
Ad

Answer this question