How do i tween in one direction perfectly

While making tweens i notice that the part isn’t perfectly on its right position. :smiley:

My Expectation for part is the part is growing on its Y Axis without moving the position

image

what happen is :
image

Script :


wait(10)
local Info = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local Size = {
	Position = Vector3.new(script.Parent.CFrame.X, script.Parent.CFrame.Y + 11 , script.Parent.CFrame.Z),
	Size = Vector3.new(24, 11, 22)

}

TweenService:Create(script.Parent, Info ,Size):Play()
wait(1)

local Info = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local Size = {
	Position = Vector3.new(script.Parent.CFrame.X, script.Parent.CFrame.Y - 11, script.Parent.CFrame.Z),
	Size = Vector3.new(24, 1, 22),


}
TweenService:Create(script.Parent, Info ,Size):Play()
script.Parent.CFrame.X

What is this supposed to be? If you don’t need a CFrame value, and you convert it to a Vector3 anyways, why use one? Use the part’s position values: script.Parent.Position.X

Writing script.Parent.Position.X + 24 will always move the part on its X axis, regardless of its rotation. If you want the part to move to ITS right (which might not be the X-axis if it’s rotated) then use this:

script.Parent.Position + (script.Parent.CFrame.RightVector * 24)

This moves the part 24 studs to its right. If you want it to go left, use -24 instead of 24. If you want it to go forward, use LookVector instead of RightVector.

I hope this helps!

it’s supposed to be a lava that is increasing in one direction

like this illustration :

.-------

“The text is updated, Help is always appreciated”

Oh okay, I understand now. If you want to make the part look like its growing, but keeping its “bottom in one place” (to make it seem like it’s only growing upwards), then move the part up HALF as much as the size changes.

For example, let’s say there’s a part that is (1, 1, 1) in size and is at position (0, 0, 0). If you want to increase its size to (1, 10, 1), then first you need to check how much it grew. In this case, its Y size grew from 1 to 10, meaning it grew 9 studs up. Now, you have to set its position half this much up. So the end position will be (0, 4.5, 0).

If the part is shrinking, do the same but instead of increasing the position by 4.5, decrease it.

As I can see in your post, the size goes from (24, 11, 22) to (24, 1, 22). It means it shrunk 10 studs. In this case, you have to move it down by 5 studs.

This will be the second tween:

Position = Vector3.new(script.Parent.CFrame.X, script.Parent.CFrame.Y - 5, script.Parent.CFrame.Z),
	Size = Vector3.new(24, 1, 22),
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.