Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

3 comments

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.

0

I have tried doing this with server scripts, but then it completely did not work in the published game.

0

i edited my answer

1 answer

-- 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.

2 comments

0

Why not Players:FindFirstChild("DanielCXI") tho

0

Or even script.Parent:FindFirstAncestorOfClass("Player") since the gui is parented to someone's PlayerGui

This discussion is preserved as it was. New answers, comments, and votes are closed.