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

How do I combine lerp with SetPrimaryPartCFrame?

I need help with this, I don't know how to combine lerp with SetPrimaryPartCFrame

		for o=0,1,.01 do
			object:SetPrimaryPartCFrame(CFrame.new(0,0,0))
			wait(.1)
		end

I'm trying to get a model(object) to slide to 0,0,0

1 comment

0

Take a look at the lerp function in CFrame

1 answer

✓ Accepted answer

First we get the original CFrame of the primary part then we setup the lerp like this

local cf = script.Parent:GetPrimaryPartCFrame()
for i=0,1,.005 do wait()
	script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame():lerp((cf*CFrame.Angles(math.rad(90),0,0)),i))
end

That example was for rotating 90

This example is for moving to 0,0,0

for i=0,1,.005 do wait()
	script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame():lerp((CFrame.new(0,0,0),i))
end

2 comments

0

thank you!

0

:/

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