Tweening UI in a specific direction

When I click a button, I want it to tween from a certain direction (e.g. from left → inwards)

It starts off like this:


The green barriers are there just for demonstrating the direction, otherwise it wouldn’t be clear.

Similar to what is expected:
image

What actually happens:
image

I’m not sure why this is. The way I got the new position I wanted was by resizing it, taking that position and tweening it to that point.

Pretty much like this:

script.Parent.MouseButton1Down:Connect(function()
	script.Parent.Parent.Main:TweenSize(UDim2.new(0, 336,0, 310))
end)

The position refers to the position of the top left corner by default. Try adjusting the AnchorPoint’s X to 1 if you want it to be based on the top right. You’ll have to tweak the UI’s starting position a bit too, for obvious reasons.

3 Likes