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)
runService.Heartbeat:Connect(function(dt)
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 = Vector3.new(target.HumanoidRootPart.Position.X, 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 = Vector3.new(-offset.X, -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
end
else
if char:FindFirstChild('Torso') and hum.Health > 0 then
local offset = char.Torso.CFrame:ToObjectSpace(rootPart.CFrame).Position
local camOffset = Vector3.new(-offset.X, -offset.Y, -offset.Z)
hum.CameraOffset = camOffset + Vector3.new(0,0.1,0)
else
ts:Create(hum, TweenInfo.new(.055, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {CameraOffset = Vector3.zero}):Play()
end
end
end)
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.