After I click on the GUI, the code executes, but have to wait 5 seconds or less for me to click the Gui again, how can I fix this?
local frame = script.Parent.Parent.Parent:WaitForChild("Test") local open = false script.Parent.MouseButton1Down:connect(function() if open == false then frame:TweenPosition(UDim2.new(0.5, 0,0.1, 0), "Out", "Bounce", 1) open = true else frame:TweenPosition(UDim2.new(0.5, 0,-1, 0), "Out", "Bounce", 1) open = false end end)
This is because you have not set the override property to true. Also, try this script; it's more efficient.
local frame = script.Parent.Parent.Parent:WaitForChild("Test") local open = false script.Parent.MouseButton1Down:Connect(function() open = not open frame:TweenPosition(UDim2.new(0.5, 0,(open and 0.1) or -1, 0), "Out", "Bounce", 1, true) end)
The true
on line 5 will allow the tween to reverse midway.