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

        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

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

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
0
thank you! ArcticDev 9 — 7y
0
:/ User#5423 17 — 7y
Ad

Answer this question