Lerp jittering glitch?

I want to know how to make the cframe not stutter. Basically whenever I start moving, the part starts stuttering behind me, I believe its because the lerps “goal” is always changing whenever im moving causing it to stutter.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Rs = game:GetService("RunService")

local Test = workspace:WaitForChild("TestPart")

function Follow(Dt)
	local st = (Dt * 60)
	Test.CFrame = Test.CFrame:Lerp(Character.PrimaryPart.CFrame, math.clamp(0.1 * st, 0, 1))
end

Rs:BindToRenderStep("Test", Enum.RenderPriority.Last.Value, Follow)

why use lerp over an align position?

This is a testing script, doing so in the main one could cause it to lag, I’m not entirely sure tho

using an align orientation causes lag?

Could, as I said. It is also not the best way to do what im looking for since the objects im lerping are anchored

For smooth animations like that you either need to do them on the client or use something that gets smoothed (like a Motor6, AlignPosition, etc).

Otherwise, the delay between the server and the client results in choppy movement.

If you’re really set on tweening from the server though, I believe this module by SteadyOn lets you do it without the choppiness:

Ill try this out and lyk if it works, Thank you for the help!!!

1 Like

Enum.RenderPriority.Last is literally the last thing of course it’ll be laggy, change that to something higher like camera or so.

I believe the RenderPriority changes the order of when the function is run each frame (for example, Camera + 1 is after the camera updates and Camera - 1 is before the camera updates). I think worst case using a later priority could only cause it to be one frame behind, though I don’t think it would be choppy like in the video.

Even when using camera or character or any renderpriority it still stutters

Reason why you’re getting CFrame stutters is because your DT is not constant in your Lerp factor.
math.clamp(0.1 * (Dt * 60))
Basically the Speed is unpredictable. Which starts to stutter a lot. I recommend using Align Position and Orientation.

BUT In case that is not the solution u wanna hear. Here’s the smoothest i could make it.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Rs = game:GetService("RunService")

local Test = Instance.new("Part", workspace)
Test.Anchored = true
Test.CanCollide = false

function Follow(Dt)
	Test.CFrame = Test.CFrame:Lerp(Character.PrimaryPart.CFrame, 0.1)
end

Rs.Heartbeat:Connect(Follow)