Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to change the speed of how fast my part is going(CFrame)?

Asked by
Synth_o 136
7 years ago
01local RunService = game:GetService("RunService")
02local part = game.workspace:WaitForChild("Start")
03local part1 = game.workspace:WaitForChild("Finish")
04 
05local PART1_POS = part1.position
06local PART_POS = part.position
07local DURATION = 5
08 
09 
10RunService.RenderStepped:Connect(function()
11    local deg = 0*(wait(10) % DURATION)/ DURATION
12    part.CFrame = CFrame.new(PART1_POS) * CFrame.Angles(0,0,(deg),0) * CFrame.new(PART_POS)
13end)

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?

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

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.

1local TweenService = game:GetService("TweenService")
2local part = workspace:WaitForChild("Start")
3local part1 = workspace:WaitForChild("Finish")
4local tweenInfo = TweenInfo.new(5) --5 Seconds
5local goal = {};
6goal.CFrame = part1.CFrame; --Make the goal's CF part1's CF
7 
8local tween = TweenService:Create(part, tweenInfo, goal)
9tween:Play()
1
well said Goulstem, Now Ima try the TweenService for the players torso greatneil80 2647 — 7y
Ad

Answer this question