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

How do I CFrame block to block?

Asked by 6 years ago

I'm currently making a CFramed roller coaster, I would just like to know if there is any way to script a CFrame so that the model goes to the position of another block instead of manually scripting each move.

1 answer

Log in to vote
0
Answered by
zyrun 168
6 years ago
Edited 6 years ago

Sure, looks like this:

-- To instantly teleport a part, do this
local PartToCFrame = game.Workspace.Part
local GoalPart = game.Workspace.GoalPart


PartToCFrame.CFrame = CFrame.new(GoalPart.Position)

Edit: If you would like to control how long the move should take, You should use TweenService. This looks like this:

local TweenService = game:GetService("TweenService")
local PartToControl = game.Workspace.Part
local GoalPart = game.Workspace.GoalPart
local Goal = game.Workspace.GoalPart.Position

local tweenInfo = TweenInfo.new(
    5 -- Time that it will take to move the part
    -- There are more arguments that you can pass here, to search them refer to link below
)

local MoveAction = TweenService:Create(PartToControl, tweenInfo, Goal)


MoveAction:Play()

TweenInfo

Hope this helped! - Zyrun

0
In a way this is what I was looking for... I was looking for more of something that I could control the speed and such. IPhoneDrew 9 — 6y
0
Edited to your standards, please accept answer if it is what you wanted :) zyrun 168 — 6y
Ad

Answer this question