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
local RunService = game:GetService("RunService")
local part = game.workspace:WaitForChild("Start")
local part1 = game.workspace:WaitForChild("Finish")

local PART1_POS = part1.position
local PART_POS = part.position
local DURATION = 5


RunService.RenderStepped:Connect(function()
    local deg = 0*(wait(10) % DURATION)/ DURATION
    part.CFrame = CFrame.new(PART1_POS) * CFrame.Angles(0,0,(deg),0) * CFrame.new(PART_POS)
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?

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.

local TweenService = game:GetService("TweenService")
local part = workspace:WaitForChild("Start")
local part1 = workspace:WaitForChild("Finish")
local tweenInfo = TweenInfo.new(5) --5 Seconds
local goal = {};
goal.CFrame = part1.CFrame; --Make the goal's CF part1's CF

local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
1
well said Goulstem, Now Ima try the TweenService for the players torso greatneil80 2647 — 7y
Ad

Answer this question