01 | local RunService = game:GetService( "RunService" ) |
02 | local part = game.workspace:WaitForChild( "Start" ) |
03 | local part 1 = game.workspace:WaitForChild( "Finish" ) |
04 |
05 | local PART 1 _POS = part 1. position |
06 | local PART_POS = part.position |
07 | local DURATION = 5 |
08 |
09 |
10 | RunService.RenderStepped:Connect( function () |
11 | local deg = 0 *(wait( 10 ) % DURATION)/ DURATION |
12 | part.CFrame = CFrame.new(PART 1 _POS) * CFrame.Angles( 0 , 0 ,(deg), 0 ) * CFrame.new(PART_POS) |
13 | end ) |
That is what I have so far, but whenever i try it the part moves instantly, it does not move smoothly to the other part? How do you fix this?
The best way to do this would be to use TweenService.
Essentially, use the TweenInfo.new
function to declare the speed of the tween.
Use the TweenService:Create()
method to create the tween.
And finally, use the Play
function to play the tween.
1 | local TweenService = game:GetService( "TweenService" ) |
2 | local part = workspace:WaitForChild( "Start" ) |
3 | local part 1 = workspace:WaitForChild( "Finish" ) |
4 | local tweenInfo = TweenInfo.new( 5 ) --5 Seconds |
5 | local goal = { } ; |
6 | goal.CFrame = part 1. CFrame; --Make the goal's CF part1's CF |
7 |
8 | local tween = TweenService:Create(part, tweenInfo, goal) |
9 | tween:Play() |