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

Using CFrame to move an object to a position?

I have seen people using CFrames to move an object to another objects position but actually having it move and not just teleport. I was wondering how this works. You can see it is used here.

1 comment

0

You can use TweenService if you want to move parts.

2 answers

✓ Accepted answer

Use TweenService! Tweening is used for interpolating almost any numeric property of certain objects. In your case, I'm assuming, a part.

So here's how it goes;

local TweenService = game:GetService("TweenService") --gets tween service

local part = workspace.Part --gets the part (change it to your own part's address)

local tweenInfo = TweenInfo.new( --how we want our tween to play
	1, --how fast the tween is (in seconds)
	Enum.EasingStyle.Linear, --easing style
	Enum.EasingDirection.Out, --easing direction
	0, --no. of times the tween will repeat
	false, --will the tween reverse upon finishing?
	0 --how long the delay is (in seconds)
)

local goal = { --goal for our part's property, in this case, the position
	Position = Vector3.new(69,42,0) --our goal position for our part
}

local tween = TweenService:Create(part, tweenInfo, goal) --now creates the tween

tween:Play() --finally, plays it

Here are some resources; I hope this helps! https://developer.roblox.com/en-us/api-reference/class/TweenService https://developer.roblox.com/en-us/api-reference/datatype/TweenInfo https://developer.roblox.com/en-us/api-reference/enum/EasingStyle

2 comments

0

Dr_Smartypants123's lerp method works too but I feel tweening is a bit easier to manipulate.

0

Also, how would I add orientation to this?

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