Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

TweenPosition cause a delay on Gui Button?

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)

1 answer

✓ Accepted answer

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.

2 comments

0

connect is deprecated ;)

0

I edited it. It says "connect" now ;)

This discussion is preserved as it was. New answers, comments, and votes are closed.