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

Tweening a Part's position?

Hey everyone! I wanted to know if it is possible to tween the position of a part like how you would in a GUI. I need to move a part to the players location, but I want to control the time it takes to get there. A tween would work perfectly in this case.

If this would work, it would be exactly what I want: Part:TweenPosition(position,1) Is there something similar I could use? Thanks!

2 comments

1

If you already know how to Tween something in a ScreenGUI, you're good to go. That would also work with Parts.

0

Oh! Thank you!

1 answer

✓ Accepted answer

To do this, use TweenService.

local tweenService = game:GetService("TweenService")

From there, you give the created tween TweenInfo which takes parameters for the different properties the tween can have. These include time, easing styles, and the ability to reverse and repeat. TweenInfo also includes default values so if you only want to edit the time, use TweenInfo.new(n) and it will use the default values with your specified time.

local tweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	n
)

local properties = {
	Position = Vector3.new(x, y, z)
}

tweenService:Create(part, tweenInfo, properties):Play()

Use :Create() which takes the thing that is being tweened, the TweenInfo and the properties being changed as parameters. This can be made a variable and played multiple times.

References: TweenInfo, Create

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