So i'm trying to learn how to use lerp to have a part move to a certain location but the closer it gets the slower it gets and I want to know if there's a way to prevent that.

Script

game:GetService("RunService").Heartbeat:Connect(function(step)
	local position = script.Parent.dest.Value
	local speed = 5
	local list = workspace.MoveAreas:GetChildren()
	for i = 1,#list do
		if list[i].Position == position then
			script.Parent.CFrame = script.Parent.CFrame:lerp(list[i].CFrame,step/speed)
		end
	end
end)

3 comments

1

You're lerping using the CURRENT CFrame. This means as the distance to the destination becomes smaller, lerp, being a fraction of a smaller value, also moves a smaller distance. Lerp it as a constantly increasing fraction/percent of the INITIAL CFrame, not the running current CFrame.

0

I figured that but I tried using script.Parent.CFrame = Cf.CFrame:lerp(list[i].CFrame,step/speed) (cf is the cframe of its initial position) and it doesn't move at all.

0

Never mind figured out my problem was I was just using 0.1 as a test so that's why it didn't move, Thanks Cousin_Potato