Gui not tweening the way intended

Howdy. I’m trying to make a ui animation where you click a button, it stretches outwards on the x-axis first, waits 0.3 seconds, and then stretches to the full size on the y-axis. I have run into a problem where it only stretches the x-axis and not the y. Can somebody explain what’s wrong with the code?

Code

local btn = script.Parent
local menu = btn.Parent.Set

menu.AnchorPoint = Vector2.new(0.5,0.5)
menu.Position = UDim2.new(0.5, 0, 0.5, 0)

--current size = {0.256, 0},{0.615, 0}

btn.MouseButton1Click:Connect(function()
	menu.BorderSizePixel = 5
	menu:TweenSize(UDim2.new(0.256,0,0,0), "Out", "Sine", 1)
	wait(0.3)
	menu:TweenSize(UDim2.new(0.256,0,0.615,0), "Out", "Sine", 1)
end)
1 Like

The x-axis tween takes 1 second, but you’re only waiting 0.3 seconds before you start the y-axis tween.

You could either change the x-axis tween to be 0.3 seconds.
You could add true as a fifth parameter to the y-axis tween to override the other tween; however, I’m unsure whether or not this will completely stop the x-axis tween.

1 Like
local btn = script.Parent
local menu = btn.Parent.Set
local debounce = false
local size = menu.Size
menu.AnchorPoint = Vector2.new(0.5,0.5)
menu.Position = UDim2.new(0.5, 0, 0.5, 0)

btn.MouseButton1Click:Connect(function()
	if debounce then
		return
	end
	debounce = true
	menu.BorderSizePixel = 5
	menu:TweenSize(UDim2.new(0.256,0,0,0), "Out", "Sine", 1)
	task.wait(1)
	menu:TweenSize(UDim2.new(0.256,0,0.615,0), "Out", "Sine", 1)
	task.wait(1)
	debounce = false
end)
1 Like