Im trying to learn how I can smoothly move a part. Its like tweening, but for objects. Anyone know how I can do this?
How Can I SMOOTHLY Move a Part?
1 answer
You can use TweenService to smoothly move and animate baseparts (tween is short for in-between, meaning generating intermediate frames in-between two destinations).
The TweenService instance is a class, so it is done using the GetService method.
local TweenService = game:GetService('TweenService')
You'll need to set the information of the tween first. This defines how long the animation will be, the style and direction, and whatnot. This is done using TweenInfo.new().
local info = TweenInfo.new(
2, --How long the tween is played for (in seconds)
Enum.EasingStyle.Quad , --The behavior of the tween
Enum.EasingDirection.Out, --The direction of the style
0, --How many times the tween will be repeated
false, --Will the tween play in reverse as well?
0, --Delay between each interpolation.
)
You can see how the easing styles act here. Easing directions (In, Out, or InOut) just refers to if the style acts in the beginning, the end, or both of the interpolation.
Next, we need to set the goal, or what properties are going to be tweened. Since this is just moving a part, all we need to do is change the CFrame.
local goal = {CFrame = CFrame.new(0,0,0)} --Set the destination for the part to move to.
Lastly, we just need to create the tween and play it!
local part = workspace.Part --The basepart that will be tweened.
local Tween = TweenService:Create(part,info,goal)
Tween:Play() --Plays the tween. You can also do :Stop() to stop the tween.
That should be it. Here's the code altogether. Hope this helps!
local TweenService = game:GetService('TweenService')
local part = workspace.Part --The basepart that will be tweened.
local info = TweenInfo.new(
2, --How long the tween is played for (in seconds)
Enum.EasingStyle.Quad , --The behavior of the tween
Enum.EasingDirection.Out, --The direction of the style
0, --How many times the tween will be repeated
false, --Will the tween play in reverse as well?
0, --Delay between each interpolation.
)
local goal = {CFrame = CFrame.new(0,0,0)}
local Tween = TweenService:Create(part,info,goal)
Tween:Play()
3 comments
Good explained already knew it, but goood
Just say "nice explanation". No need to brag about your knowledge
Very nice answer! Thank you very much, this worked very well ;)
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
http://wiki.roblox.com/index.php?title=API:Class/TweenService
You can also use BodyPosition or RocketPropulsion
this doesn't explain a lot, im lost. Can you explain what i should do with the script provided?
can i bump?
can i bump?