Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I CFrame block to block?

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

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

2 comments

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.

0

Edited to your standards, please accept answer if it is what you wanted :)

This discussion is preserved as it was. New answers, comments, and votes are closed.