You several options.
Option 1: TweenService - TweenService would be used if you want to change a property of a part gradually.
Option 2: Lerp - Lerp would ideally be used to move something back and forth, but this is not the only functionality of Lerp.
Option 3: BodyMovers - BodyMovers are nice for projectiles, but can potentially lag.
TweenService - To use TweenService, you'd first have to initialize TweenService.
1 | local tweenService = game:GetService( "TweenService" ); |
Then, you'd want to create a new TweenInfo. You could even have a default one just by having the parameter be TweenInfo.new(), but lets create one.
1 | local tweenInfo = TweenInfo.new( 1 , Enum.EasingStyle.Quart, Enum.EasingDirection.InOut); |
You can find more info on TweenInfo.new() here: https://developer.roblox.com/en-us/api-reference/datatype/TweenInfo
Now, we need to create a new Tween, and make it for the part.
2 | CFrame = CFrame.new( 0 , 0 , 0 ); |
5 | local Tween = tweenService:Create(part, tweenInfo, Goal); |
Full code:
1 | local tweenService = game:GetService( "TweenService" ); |
2 | local tweenInfo = TweenInfo.new( 1 , Enum.EasingStyle.Quart, Enum.EasingDirection.InOut); |
4 | CFrame = CFrame.new( 0 , 0 , 0 ); |
7 | local Tween = tweenService:Create(part, tweenInfo, Goal); |
Now, you'd probably want to incorporate this into a loop. If you're using a LocalScript, use the .RenderStepped event of RunService (more info here: https://developer.roblox.com/en-us/api-reference/event/RunService/RenderStepped)
If you're using a ServerScript for whatever reason, use a while wait() do loop.
I personally think AlvinBlox covered it nice enough here: https://youtu.be/qgGDwTn0zgo
For Option 3 (BodyMovers), you could use AlignPosition, or BodyPosition. I personally would suggest using AlignPosition.
Please mark this as the answer/upvote if I've helped you with your question, and feel free to ask any questions in the comments.