Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I close a Gui Button with Visible = false?

So far I have gotten a gui to open but I am not sure how to close it. This is the script I have so far.

script.Parent.MouseButton1Down:connect(function()

function leftClick()
	(script.Parent.Parent:FindFirstChild("Frame").Visible = false
    	script.Parent.Visible = false
end)

What should I change with this script to make it so it closes my gui?

3 answers

I am fairly new to coding myself, and I don't know why that doesn't work, but here is a short script I have saved on my own project.

script.Parent.TextButton.MouseButton1Click:Connect(function()--detect a click on the button
	local TextButton = script.Parent.TextButton --define the textbutton
	if TextButton.Visible == true then --if its visible then
		TextButton.Visible = false --make it invisible
	elseif TextButton.Visible == false then -- if its not visible
		TextButton.Visible = true --make it visible
	end
end)

If you want to do it like that then you can do this.

script.Parent.MouseButton1Down:Connect(function(leftClick)

function leftClick()
	script.Parent.Parent:FindFirstChild("Frame").Visible = false
	script.Parent.Visible = false
end)

The script should work

function leftClick()
    (script.Parent.Parent:FindFirstChild("Frame")
        script.Parent.Visible = not script.Parent.Visible 
end)
leftClick() 

This discussion is preserved as it was. New answers, comments, and votes are closed.