Recently, I was making an open/close GUI For some reason, it won't work, since the GUI won't close when I click on a TextButton that should close it. I have checked and rechecked it, any help?
Script:
Player = game.Players.LocalPlayer StarterGui = game.Workspace:WaitForChild("StarterGui") ScreenGui = StarterGui:WaitForChild("ScreenGui") Button = ScreenGui:WaitForChild("OpenClose") ButtonBacking = ScreenGui:WaitForChild("ButtonBacking") Open = true Button.MouseButton1Down:connect(function(open) if Open == true then Button.Text = "Close Teleports" ButtonBacking.Visible = false Open = false elseif Open == false then Button.Text = "Open Teleports" ButtonBacking.Visible = true Open = true end end)
Thanks!
There is a simple issue with this. You use WaitForChild() to find "StarterGui" in workspace. This will yield the script until it finds startgui in workspace. Also, you can not see a script from startergui, It has to be from playergui. Try this:
Player = game.Players.LocalPlayer PlayerGui= Player.PlayerGui ScreenGui = PlayerGui:WaitForChild("ScreenGui") Button = ScreenGui:WaitForChild("OpenClose") ButtonBacking = ScreenGui:WaitForChild("ButtonBacking") Open = true Button.MouseButton1Down:connect(function() if Open == true then Button.Text = "Close Teleports" ButtonBacking.Visible = false Open = false elseif Open == false then Button.Text = "Open Teleports" ButtonBacking.Visible = true Open = true end end)
Basically a problem with your variables Also on line 8, you should have open as an argument. MouseButton1Down takes no arguments or parameters ~~Hope i helped