How would you go about making a gui open and close?

Hey! I recently made this makeup gui and it works but I can’t get it to open and close. I’m not an amazing scripter or know much about scripting and I know that closing and opening is probably really simple but I can’t figure out what to do. Every script I’ve attempted to make for it does not work and won’t show an error on output so I’m lost. Please help!

5 Likes

Are you trying to make it so that a button will open/close a frame? Just trying to get at what your issue is…

Yes. Also thank you for taking the time to help! I really appreciate it!

1 Like
Button.MouseButton1Click:Connect(function()
    GUI.Visible = not GUI.Visible
end)

Edit:
I changed Enabled to Visible. Enabled is for ScreenGui objects, Visible is for objects such as Frame, Buttons etc.

10 Likes

@Calilies

    [buttonA] = frameA;
    [buttonB] = frameB;
}
for button,frame in pairs(frames) do
    button.MouseButton1Click:connect(function()
        if frame.Visible then
            -- If we try to reopen the current frame, close it
            frame.Visible = false
            return
        end
        -- Close all frames and make ours visible
        for k,v in pairs(frames) do
            -- 'v == frame' is true if it's our frame
            v.Visible = v == frame
        end
    end)
end```
You should also check out the ROBLOX Wiki. It has some nice tutorials for Lua and stuff like opening/closing GUIs.
4 Likes

No problem! Here is what I did to make mine work.

  1. Put local script under gui button that you want to open another frame with

  2. My script :

function onClick()

if (script.Parent.Parent.Parent.(Name Of your frame goes here).Visible)then
	
	script.Parent.Parent.Parent.(Name Of your frame goes here).Visible = false
	
else
	
	script.Parent.Parent.Parent.(Name Of your Frame goes here).Visible = true
	
end

end

script.Parent.MouseButton1Down:Connect(onClick)

This all depends on how your properties are set up. Let me know if this does not work for you

11 Likes

Think you might be better off using MouseButton1Click since it can stop accidental functions from happening.

Remember that MouseButton1Down and MouseButton1Click is an event which can be used by TextButtons and ImageButtons.

7 Likes