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 make a toggle visiblitiy gui button?

So far I have this. It's really just an infinite loop. XD I can make separate open and close gui buttons using visibility, but cannot make them in one.

Here's what I have:

script.parent.MouseButton1Click:connect(function(Open)
	if game.StarterGui.ExploreID.ProfileShade.Visible==false then
	 game.StarterGui.ExploreID.ProfileShade.Visible=true
	if game.StarterGui.ExploreID.ProfileShade.Visible==true then
		game.StarterGui.ExploreID.ProfileShade.Visible=false
	end
	end
end)

I have no clue where to go from here, I'm learning through trial and error. XD

3 comments

0

use elseif on line 4 instead of if...

0

THANKYOU

0

IT STILL DOESN'T WORK :(

1 answer

If you are trying to make a button that makes a GUI visible if you click it, then makes it invisible if you click it again, use this:

local Gui = script.Parent.ProfileShade --This is assuming that this button is in ProfileShade. Make sure you do not define the one is StarterGui. That is the template you start out with.
script.Parent.MouseButton1Click:connect(function(Open) --Make sure to capitalize Parent
    if Gui.Visible==false then 		
    	Gui.Visible=true
    	else Gui.Visble = false --If it is not false, it has to be true.
    end
end)

Hopefully this helps!

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