How to Tween In One Direction

  1. What do you want to achieve?
    I have a wood part that I want the size to grow only in one direction. For example, it will grow towards my mouse in one direction, not in both.

  2. What is the issue?
    As of now if you tween size it will grow in both directions and I want it to be in one direction only.

  3. What solutions have you tried so far?
    I tried changing its CFrame and some random math and it did not work as I desired.

Hmm!

I’d suggest trying to tween the position in the same direction by half the amount!

If you tween just the size:
(o is the origin)

     [----o----]       Start (11 long)

[---------o---------]  End   (21 long)  (+10 longer)

Also tween the position +5 as well

     [----o----]       Start (11 long)

     [---------o---------]  End   (21 long)  (+10 longer)

Hope this gives you an idea of what to try!

7 Likes

First off, you should know where x, y, and z points/faces at.

If you don't know

image

So, what you can do is add whatever size the growth you want to be to the component.
Say you want to expand in the x direction, what you can do is:
CFrame.new(wood.CFrame.X + 10, wood.CFrame.Y, wood.CFrame.Z), where wood is the part you want to change the size. If you want a more effective method, add Vector3.new(10, 0, 0) to the CFrame. All it simply does is add each x, y, z of the vector to the CFrame. So, cf + v3 = cf(cf.X + v3.X, cf.Y + v3.Y, cf.Z + v3.Z), where cf is a CFrame, and v3 is a Vector3. And since you’re tweening it, use :lerp() or TweenService.
Edit:

Extra information

CFrame Math Operations

2 Likes