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.
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.
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.
local Goal = {
CFrame = CFrame.new(0, 0, 0);
}
local Tween = tweenService:Create(part, tweenInfo, Goal);
Tween:Play();
Full code:
local tweenService = game:GetService("TweenService");
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut);
local Goal = {
CFrame = CFrame.new(0, 0, 0);
}
local Tween = tweenService:Create(part, tweenInfo, Goal);
Tween:Play();
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.
2 comments
try using TweenService ? I don't know if thats what you need but it may work
Yeah, TweenService would probably be your best bet.