Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a open & close menu?

Asked by 5 years ago
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

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 Sergiomontani10 236 — 5y

3 answers

Log in to vote
0
Answered by
T0XN 276 Moderation Voter
5 years ago
Edited 5 years ago

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)
Ad
Log in to vote
1
Answered by
valchip 789 Moderation Voter
5 years ago
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.

0
...The use of ":Connect()" in this answer doesn't really mean you had to make a new post entirely. T0XN 276 — 5y
0
dude I did not rewrite this just for that problem, he posted that meanwhile I was writing I swear valchip 789 — 5y
0
Apologies for making assumptions. T0XN 276 — 5y
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)?
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. valchip 789 — 5y

Answer this question