So, I'm trying to make a part that follows a certain path (the path being another part) in the game. I just need the part to slowly move across this line when it's told, and to stop when it's told. I've tried doing certain things with body velocity, and body force, but couldn't seem to make anything work? Every time I did the part either wouldn't move or it wouldn't follow the line it's suppose to follow? Anything helps, just need pointed in the right direction. Thanks.
You can use TweenService
for it. It is very simple. Here's how it works:
local TS = game:GetService("TweenService") Part = ____________ --The part you want to move EndPos = ____________ --The Vector3 position where the part will go goal = {Position = EndPos} --Setting the goal local info = TweenInfo.new( 5, -- The time in seconds it will take to reach the goal Enum.EasingStyle.Linear Enum.EasingDirection.InOut 0, false, 0 ) local tween = TS:Create(Part, goal, info) tween:Play() --Plays the tween animation
Hello, this is how you do tweening properly.
local TweenService = game:GetService("TweenService") local part = workspace.Part --of course you're gonna have to put in your part's address local endPart = workspace.EndPart --put in your end part's address local tweenInfo = TweenInfo.new() --* 10, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0 end) local goal = { Position = endPart.Position } local tween = TweenService:Create(part, tweenInfo, goal) tween:Play()
Use tween:Pause()
to freeze the part's position and tween:Play()
to continue.
Resources that may help: https://developer.roblox.com/en-us/api-reference/class/TweenService https://developer.roblox.com/en-us/api-reference/datatype/TweenInfo* https://developer.roblox.com/en-us/api-reference/function/TweenBase/Pause