How do i make the Menu be closeable from the Menu Button instead of only from the X button

So as i know how to make the Menu go open and closed, you open the Menu through the Menu Button and you close the Menu through the X Button. How do i make the Menu be closeable through the Menu Button instead of only the X Button?

CloseButtonScript:

Screenshot 2021-06-17 202449

OpenButtonScript:

Screenshot 2021-06-17 202712

Explorer:

Screenshot 2021-06-17 202803

I think this is what you are looking for from what you said?

thing1.MouseButton1Click:Connect(function()
thing2.Visible = not thing2.Visible
end)

in OpenButtonScript or CloseButtonScript?

I don’t think you should have two different scripts to open and close it.

WAIT NO, OpenFrameScript or CloseFrameScript

not OpenButtonScript or CloseButtonScript

i mean i had images of it showing

Just combine them and use the script I gave you.

so (thing) is just the frame or stuff i made

wait but wouldnt the TextButton’s not work?

You would first select the button which opens it and do the mousebuttonclicked and in the function connected you would do an if statment to see if the UI is open or not. If the UI is open then close it and if the UI is closed then open it using the .visible.

Very simple to do.

Here is some simple reference code I did quick (have not tested it but should work fine);

local frame = script.Parent.Parent
local Button = script.Parent
	Button.MouseButton1Click:Connect(function()
	if frame.Visible == true then
		frame.Visible = false
	else
		frame.Visible = true
	end
end)

That is kinda the idea on how you can do it but you have not done an if statement to see if it equals to visible or not.

where does it go in? in the Close TextButton or in the Open TextButton? or just inside the MenuFrame?

1 Like

Wait why do u have 2 UI’s with one open and one close? Am I not reading your post correctly? I though you said you want the button which you open it with also close it?

If what I thik you mean then the button which you open the UI with as there is no need for 2 UI’s when u can do it the same with one button.

so i put the localscript inside the menuframe?

Why do u have 2 buttons when u want one button to do both open and close?

OHHHHHHH WAIT I PUT THE LOCALSCRIPT INSIDE OPEN ok

Yes but I am still confused why u would have 2 buttons when u said u want it to just do one?

idk why tho i did this a few months ago