local ScreenGui Production function wait if Visible = true then wait(5) then visible = false end
I'd give you a walkthrough of what you did wrong, but it is just about everything.
Lets start with how you should define the gui. The localscript should be placed directly inside of your TextButton/ImageButton. This way, it is easily accessible by using script.Parent
.
local ScreenGui = script.Parent
Next, you need to setup your function. The correct syntax to do so is:
function [name] (arguments)
[code]
end
function Click() end
Now you can manipulate the Visiblity of your Gui.
function Click() ScreenGui.Visible = not ScreenGui.Visible end
And finally, you need to tie your function to an event. Events in roblox are "listeners" that will fire whenever a specified action occurs. You tie functions to Events in order to make them, well, functional :)
Full product:
local ScreenGui = script.Parent function Click() ScreenGui.Visible = not ScreenGui.Visible end --MouseButton1Click is the event that handles clicking for UI ButtonObjects script.Parent.MouseButton1Click:Connect(Click)
bin = script.Parent function Click() script.Parent.Parent.(NameOfTheGui).Frame.Visible = true end bin.MouseButton1Click:connect(Click)
2.Add another script into button or imageButton And the Button's parent should be the opened GUI then Write this
bin = script.Parent function Click() script.Parent.Visible = false end bin.MouseButton1Click:connect(Click)