My button takes two clicks for my Gui to show up when it used to take one

Hello.
One of my Gui’s used to show up when the button Gui was pressed once. I’ve added a few things to the Gui and now it takes two clicks to show up. It tweens onto the screen from the bottom. I’m not sure how I can get it back to one click.

Position of Gui when closed (below the screen boundaries):
image

Position of Gui when open:
image

Script inside of the button:

local open = true
script.Parent.Parent.Settings.Enabled = true

script.Parent.MouseButton1Click:Connect(function()
	if open == true then
		open = false
		script.Parent.Parent.Settings.MainFrame:TweenPosition(UDim2.new(0.321, 0,1, 0), "InOut", "Quad", 0.5, true)
	else
		open = true
		script.Parent.Parent.Settings.MainFrame:TweenPosition(UDim2.new(0.321, 0,0.147, 0), "InOut", "Quad", 0.5, true)
	end
end)

There is nothing wrong with the opening of the Gui, but I hate how it takes two clicks to open it. I have no idea what the issue could be so any help is greatly appreciated. :slight_smile:

it’s probably because you have open = true when it should be false
(the gui doesn’t appear yet when you first run the game)
change it to

local open = false

should fix the issue

Try This, I hope this works:

local open = false
script.Parent.Parent.Settings.Enabled = true

script.Parent.MouseButton1Click:Connect(function()
	if open == false then
		open = true
		script.Parent.Parent.Settings.MainFrame:TweenPosition(UDim2.new(0.321, 0, 0.147, 0), "InOut", "Quad", 0.5, true)
	else
		open = false
		script.Parent.Parent.Settings.MainFrame:TweenPosition(UDim2.new(0.321, 0, 1, 0), "InOut", "Quad", 0.5, true)
	end
end)

Thank you both. I’ve got it working now! :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.