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

How to make a open & close menu?

function leftClick(mouse)
	 script.Parent.Parent.Box.Visible = true
end
script.Parent.MouseButton1Click:connect(leftClick)

function leftClick(mouse)
	script.Parent.Parent.Box.Visible = false
end
script.Parent.MouseButton1Click:connect(leftClick)

Thats the script I have and it will only open, not close

1 comment

0

set it where it checks if its open and if its not then it closes else if its not open then it opens it

3 answers

✓ Accepted answer

If you want to go the shorter route, try setting the visibility to the opposite of what it is now. You didn't exactly specify if you wanted to do anything other than open or close the menu, but if you wanted some event to be fired in between, definitely go with one of the other answers.

node.MouseButton1Click:Connect(function()
	button.Visible = not button.Visible
end)
local gui = --locate gui
local textbutton = --locate textbutton

textbutton.MouseButton1Click:Connect(function()
	if gui.Enabled == true then
		gui.Enabled = false
    else
		gui.Enabled = true
end

Just try that, local script inside StarterGui.

3 comments

0

...The use of ":Connect()" in this answer doesn't really mean you had to make a new post entirely.

0

dude I did not rewrite this just for that problem, he posted that meanwhile I was writing I swear

0

Apologies for making assumptions.

Try this:

local frame = script.Parent.Parent.Frame

script.Parent.MouseButton1Click:connect(function()
 if frame.Visible == false then
  frame.Visible = true
 else
  frame.Visible = false   
 end
end)?

1 comment

0

:Connect()* :connect() is deprecated also give a bit of info where this script should go. I mean ik where this should go but I bet Pixel does not.

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