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

CFrame.lerp not working correctly?

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

✓ Accepted answer

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

1 comment

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.

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