Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to Tween a Part's Size in a Single Direction?

I am looking to tween a part's size in a single direction. Currently, when I tween the part's size, it tweens evenly from both sides.

How could I get it to shrink to the desired size by only shrinking from a single side?

1 answer

✓ Accepted answer

You can tween both the size and position to give the illusion that it's tweening to one size instead of both.

The following script will resize a part to 20 studs long left/right depending if the part size is bigger or smaller than 20 without resizing the other size.

TweenService = game:GetService("TweenService")

part = script.Parent
newSize = 20
		
endSize = Vector3.new(part.Size.X, part.Size.Y, newSize)
endPosition = part.Position + Vector3.new(0,0, (part.Size.Z/2) - (newSize/2))

goal = {
	Size = endSize,
	Position = endPosition
}

timeInSeconds = 3

tweenInfo = TweenInfo.new(timeInSeconds)
tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()


1 comment

0

Perfect! Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.