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

Why doesn't this script work?

It's supposed to make the player change teams and hide a team selection GUI while doing so.

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Visible = false
player.TeamColor = BrickColor.new("Br. yellowish orange")
player:LoadCharacter()
	
end)

It changes teams, but doesn't hide the GUI.

2 answers

✓ Accepted answer

Did you verify that 'script.Parent.Parent' points to the GUI that you want to set invisible? One way you could check this is to give the GUI a name, add a debug print:

print(script.Parent.Parent)

And see that the name matches what is printed when the script runs.

On a side note, assuming you are running this as a LocalScript, see the notes for LoadCharacter:

  • "This item should be used in a Script to work as expected online. "

3 comments

0

Indeed it does. An interesting thing to note is that the visibility portion will work fine by itself but doesn't work when included with the team changing part.

0

Actually, after testing this, if this GUI is by default visible, then respawning will clone a new GUI

0

Unselecting "ResetPlayerGuiOnSpawn" in the StarterGui properties worked. Thanks. <3

I'm not sure that you can use LoadCharacter() in a local script

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