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

How do I combine lerp with SetPrimaryPartCFrame?

Asked by 7 years ago

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

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

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

0
Take a look at the lerp function in CFrame User#5423 17 — 7y

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

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

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

That example was for rotating 90

This example is for moving to 0,0,0

1for i=0,1,.005 do wait()
2    script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame():lerp((CFrame.new(0,0,0),i))
3end
0
thank you! ArcticDev 9 — 7y
0
:/ User#5423 17 — 7y
Ad

Answer this question