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

Why doesn't this script work?

Asked by 8 years ago

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

Log in to vote
0
Answered by
IPsec 35
8 years ago

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. "
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. Green_Lemon 5 — 8y
0
Actually, after testing this, if this GUI is by default visible, then respawning will clone a new GUI IPsec 35 — 8y
0
Unselecting "ResetPlayerGuiOnSpawn" in the StarterGui properties worked. Thanks. <3 Green_Lemon 5 — 8y
Ad
Log in to vote
0
Answered by
ItsMeKlc 235 Moderation Voter
8 years ago

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

Answer this question