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

CFrame.lerp not working correctly?

Asked by 8 years ago

So, I'm trying to make one part lerp smoothly to the other part's position, but it's not working correctly. Here's my code.

local RS = game:GetService("RunService")
local p1 = workspace.Part1
local p2 = workspace.Part2
local part = Instance.new("Part", workspace)
part.Anchored = true

wait(6)

RS:BindToRenderStep("LerpToPos", Enum.RenderPriority.Camera.Value, function()
    local alpha = 0
    alpha = alpha + 0.05
    local point = p1.CFrame.lerp(p2.CFrame, 0.2)
    part.CFrame = point
    if alpha == 1 then
        RS:UnbindFromRenderStep("LerpToPos")
    end
end)

It doesn't seem to work correctly, and it always spits out this error: Players.Player.Backpack.LocalScript:12: bad argument #2 to 'lerp' (CFrame expected, got number) Anyone know why? I read on the wiki for the function and I have the argument in the right place, sooo I dunno. Thanks, everyone who reads this.

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

lerp is a method and you are calling it like a function. Line 12 should be local point=p1.CFrame:lerp(p2.CFrame,.2)

0
Thanks! It worked, and I can't believe that I missed that colon xD I kept reading it and I thought it was there, but I guess not. dudemanjude 10 — 8y
Ad

Answer this question