Tweening a part

Hello DevForum. I am trying to recreate this effect with a part: https://gyazo.com/b9b84b6d82e5986a581b163a1ea7d5b0

I tried using tweenservice, but whenever I change the size, both sides of the part move: https://gyazo.com/314598834f78b807f02627dba7150875

As you can see, it moves both sides instead of just going forward. I noticed in the first gyazo when I changed the size, it also changed the Z value of the position. I realized I could just tween the size and the position to get the outcome I want, but what would you do if you don’t know where the position would be?? Any help would be really appreciated!

1 Like

Position/Size of the part is based off the Center of the part, and not Corners,

If you know that, you should tilt that the center is basically 50% of the total Size,
So you have to do half the Size changed to move a part from a single side without excess.

example, if you add 4 Size, it should be Position 2.

1 Like

So would it be something like

Position = Vector3.new(part.Position.X, part.Position.Y, part.Size.Z / 2)

No - that’s wrong. Here’s what your goal table should be:

local deltaSize = newSize - part.Size
local goal = {
     Size = newSize;
     Position = part.Position - (deltaSize/ 2);
}
2 Likes

No, because you’re taking 50% of the Part’s Total Size,
You have to divide in 2 how long the Part Size have changed,

If you grow the part to +5, then you move it to +2.5

2 Likes