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

Help with CFrame. How to make this go to a point with a kind of tween?

Hello, So I have this script I was working with, instead of it just moving, how would I get it to move to another brick. Is there any other way to do this? I see this way kind of tweens the brick rather than just moving it. If I wanted this script to cframe to another part with this 'Tween', how would I accomplish that. Example are greatly appreciated. :)

Thanks, Antux

for i = 0,5,0.05 do
	platechosen.CFrame = platechosen.CFrame*CFrame.new(0,(0.05*(-5)),0)
	wait()
end

1 comment

1 answer

Use the method CFrame:lerp. It works like this: a:lerp(b, 0.25) will give a CFrame 25% of the way from a to b, assuming both are CFrames.

Now all you have to do is smoothly move that number from 0 to 1 with a for loop:

local a = platechosen.CFrame
local b = targetBrick.CFrame

for i = 0, 1, 0.05 do
	platechosen.CFrame = a:lerp(b, i)
	wait()
end

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