How to Change the Direction of a Tween?

Hello,

This script is fully functional except for the fact that the UI’s size decreases upwards.

local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
					local tween = TweenService:Create(cooldown, tweenInfo, {Size=UDim2.new(0.6, 0, 0.008, 0)})
				
					tween:Play()
				

In other words, the UI’s size is tweening to match the UDim2 value, but the top is staying the same while the bottom of the UI moves upwards. I would like the bottom of the UI to stay the same, while the top moves downwards to match the UDim2 value.

Thank you, and if you need anymore information please let me know :slight_smile:

You’ll have to tween its size as well as its position to stay at the end.

1 Like

Set the AnchorPoint of the UI to (0, 1) and adjust its position so that it ends up back where you wanted it.
Now, when you resize the UI, it should resize such that its top edge moves down and its bottom edge stays fixed.

AnchorPoint specifies what part of the GUI object should be at its Position.
If AnchorPoint is (0, 0), then the top left corner is at its Position.
If AnchorPoint is (0, 1), then the bottom left corner is at its Position.
If AnchorPoint is (0.5, 0.5), then the center is at the Position (and if you tweened its size, then it would grow/shrink evenly in all directions)

Another option is to also tween the Position, as the above post suggests.
Instead of:

{Size=UDim2.new(0.6, 0, 0.008, 0)}

do:

{Size=UDim2.new(0.6, 0, 0.008, 0), Position=UDim2.new(0.2, 0, 0.992, 0)}

assuming your object is placed at bottom center.

6 Likes

Perhaps a visual will help?

As you can see, the bottom is moving up. I want the top to move down.

Check out @Eestlane771’s answer, as this is the easiest solution.

1 Like