I am making a GUI which has a Show/Hide button. For some reason, this does not work. The other problem is when I try to run it in Roblox studio and change the visibility there, it does not turn off. There are no syntax errors detected by Roblox studio. This is also being used in a Seat so when you sit on it it gives you the GUI (will be placed in seat.
Here is the code:
Guithing = script.parent.parent.Frame --Only frame object there function onClick() if Guithing.Visible == true then Guithing.Visible = false elseif Guithing.Visible == false then Guithing.Visible = true end end script.parent.MouseButton1Click:connect(onClick)
Here is the folder structure:
Seat
-StarterGui
--ScreenGui
---ControlGui
----Frame (To Hide)
-----...22 text labels...
----TextButton (Button To Hide)
Are there any errors in the output? Also I suggest replacing
function onClick() if Guithing.Visible == true then Guithing.Visible = false elseif Guithing.Visible == false then Guithing.Visible = true end end
function onClick() Guithing.Visible = not Guithing.Visible end
to take up less space
parent needs to be Parent
and im assuming you tried to turn visible off in the StarterGui folder
in studio, you have to go to the player in Players and find the Gui and turn it off there
Guithing = script.Parent.Parent.Frame -- you probably need to change this now function sit() Guithing.Visible == true end function off() Guithing.Visible == false end script.Parent.Touched:connect(sit) script.Parent.TouchEnded:connect(off)
or to keep it your way
local player = game.Players.PlayerAdded() Guithing = script.Parent.Parent.Frame -- you probably need to change this now function sit() local clone = Guithing:Clone() clone.Parent= player.PlayerGui:FindFirstChild(sit.Name) clone.Visible = true end function off() player.PlayerGui:FindFirstChild(sit.Name).GuiThing:Destroy() end game.Workspace.Seat.Touched:connect(sit) script.Parent.Parent.Parent.Seat.TouchEnded:connect(off) -- name "Seat" what ever it is you are naming it in Workspace