Character Jittering due to Lock On Script

As seen in the video above, my player character jitters heavily when walking backwards ONLY on server (left side) and not on client (right side) while using lock-on. (It is hard to see in video due to low fps but in game it is extremely noticeable)

	dt = (lastDelta + dt)/2
	lastDelta = dt
	camera.FieldOfView = defFov + Lerp(lastVelocity, rootPart.AssemblyLinearVelocity.Magnitude / divisor, 0.15)
	lastVelocity = camera.FieldOfView - defFov
	if target then
		local targetPosition =, char.HumanoidRootPart.Position.Y, target.HumanoidRootPart.Position.Z)
		local newCFrame = CFrame.lookAt(char.HumanoidRootPart.Position, targetPosition, char.HumanoidRootPart.CFrame.UpVector)
		char.HumanoidRootPart.CFrame = newCFrame

		local offsetX = rootPart.CFrame.RightVector * Offset.X
		local offsetY = rootPart.CFrame.UpVector * Offset.Y
		local offsetZ = rootPart.CFrame.LookVector * Offset.Z

		local offset = char.Torso.CFrame:ToObjectSpace(rootPart.CFrame).Position

		local camOffset =, -offset.Y, -offset.Z)
		local offset = offsetX + offsetY + offsetZ
		local cameraPosition = rootPart.Position + offset + camOffset

		local targetCFrame = CFrame.lookAt(cameraPosition, target.HumanoidRootPart.Position, rootPart.CFrame.UpVector)
		camera.CFrame = camera.CFrame:Lerp(targetCFrame, dt * Speed)
		if (target.HumanoidRootPart.Position - rootPart.Position).Magnitude > 110 then
			target = nil
			lockOn.Parent = script
			camera.CameraType = Enum.CameraType.Custom
			UIS.MouseIconEnabled = true
			UIS.MouseBehavior = Enum.MouseBehavior.Default
		if char:FindFirstChild('Torso') and hum.Health > 0 then
			local offset = char.Torso.CFrame:ToObjectSpace(rootPart.CFrame).Position

			local camOffset =, -offset.Y, -offset.Z)

			hum.CameraOffset = camOffset +,0.1,0)
			ts:Create(hum,, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {CameraOffset =}):Play()

I believe this error is caused by changing the CFrame of the character’s humrp under the if target then statement, but I don’t know how to fix it.

Is this a server script or local script. If it’s a not a local script try changing it to local.

It’s a local script, the issue is client to server replication

Ok so you should use render stepped instead since heart beat runs every frame I believe.

Sadly didn’t work but using renderstepped is probably better over heartbeat

Heartbeat is for physics,
RenderStepped for rendering.

Obviously, RenderStepped is better.

How doesn’t it work?

Updates in the HumanoidRootPart’s CFrame properties are counted as physics and thus automatically replicated from client to server. The humanoidrootpart is noticeably rapidly jittering on the server while there are no issues on client, so I can assume that the issue is related to the changing of the HumanoidRootPart CFrame, but I have no idea how I would fix it.

then it’s ping problem, I’m sure.
I think the solution is using smoother movement.

(if you do it on the server it looks jittery on the client, else it looks jittery on the server (if my assumption is true))

What do you mean by smoother movement?

Just replicate the character position smoothly. Note I think Roblox doesn’t give tools for this.

I fixed it by using align orientation hooray

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.