CFrame Lerp being jittery

I am making a Pet Follow system and I’m Lerping the PetModel:GetPivot() CFrame to the HumanoidRootPart * an offset, the issue is that its very choppy even though its in a RenderStepped event.

game:GetService("RunService").Heartbeat:Connect(function(dt)
	if not Player then return end
	if not Player.Character then return end
	if not Player.Character.PetFolder then return end
	local count = 1
	for i, petModel in ipairs(Player.Character.PetFolder:GetChildren()) do
		local LerpedCFrame
		if i%2 == 0 then
			LerpedCFrame = petModel:GetPivot():Lerp(Player.Character.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(-1,0,3*math.floor(count))) * CFrame.Angles(0, math.rad(-90), 0), dt * 15)
			
		else
			LerpedCFrame = petModel:GetPivot():Lerp(Player.Character.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(1,0,3*math.floor(count))) * CFrame.Angles(0, math.rad(-90), 0), dt * 15)
		end
		petModel:PivotTo(LerpedCFrame)
		count += .5
	end
end)

Here is a video of the system in action

1 Like