I dont really know why this isnt working why cant i do like this when i clicked on the textbutton then i close the gui but it dosent seem to work. Heres the code
function onClick() game.StarterGui.ChooseLevel.Main.Visible = false end script.Parent.MouseButton1Click:connect(onClick)
Try making a local script inside the text button and then paste the following code in it:
script.Parent.MouseButton1Click:connect(function() local GUI = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ChooseLevel"):WaitForChild("Main") if GUI .Visible then GUI.Visible = false script.Parent.Text = "Open" else GUI.Visible = true script.Parent.Text = "Close" end end)
I even added some extra code so it changes the button text to say "Open" or "Close"!
You are supposed to find the GUI in the playerGui, not the StarterGui: Game.Players.LocalPlayer.PlayerGui.ChooseLevel.Main.Visible . I believe you are setting the Gui to not show up when new players join the game.