Open and close Gui is not working

Hey guys, I made a simple open and close gui. It doesn’t open for some reason though.

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.MainFrame.Visible = not script.Parent.Parent.MainFrame.Visible
end)


Help is needed quickly, thanks.

2 Likes

A simple fix would be

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


If this Helps, please accept answer. thanks :)
1 Like

Still doesn’t work, unfortunately, sorry.

This doesn’t allow for a toggle however. You would have to use “not” to inverse the current visibility for it to toggle.

1 Like

Are you getting any errors in the output?

Also, are you sure that your Frame is on screen? If you manually toggle the visibility, does it appear on screen?

1 Like

Sorry i did not see the toggle, I rewrote the code.

1 Like

Ooof, for some reason it doesn’t pop up when I toggle the visibility. Any idea why?

Rewrite the script. I know this sounds stupid but it probably will work. There is probably a tiny error. The script should work tho

1 Like

What exactly is supposed to be in the Frame? Are you sure it has contents and isn’t transparent? Is it’s .Position on screen? Is it’s .Size large enough to be seen?

1 Like

Ok, for some reason I can’t see it when I toggle visiblity manually in game. How can I fix?

Nope, position is fine. Size is fine. Transparency is fine.

script.Parent.BackroundTransparency = 0
script.Parent.Position = Udim2.new(0.5,0,  0.5,0)
1 Like

You didn’t answer all my questions. What is the Frame supposed to represent? Was it able to be seen at a previous point?

1 Like

I think he just wants a Open and close script not a reposition script.

Ok, in studio it can’t be seen either for some reason

You could use a local on/off to indicate whether or not it’s on, for example.

local btn = script.Parent
local btn2 = (DIRECTORY.HERE)
local frame = (DIRECTORY.HERE)

btn.MouseButton1Click:Connect(function()
if open == false then
		   Frame.Visible = true
		   open = true
	   else
		if open == true then
			Frame.Visible = false
			open = false
		else
		end
		btn2.(DIRECTORY.HERE).MouseButton1Click:Connect(function()
			open = false
			Frame.Visible = false
		end)
	  end
end)

Or just make a script that makes one gui open and close.

1 Like

Do you have the ScreenGui Enabled = true?
screenGui is the script.Parent.Parent

1 Like

Omg, the script SETS everything so it is not visible. I am not dumb

Is the parent ScreenGui Enabled?

Make sure the: Screen GUI is enabled, it is visible, background transparency is 0 and the position is on screen