Aiming Camera bugging out

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Fix camera issue.
  2. What is the issue? Include screenshots / videos if possible!
    Aiming camera bugs out when the character is moving.

Please tell me what I did wrong, I tried to fix it many times :frowning:

AimClient

UserInputService.InputBegan:Connect(function(Input)
	local plr = game.Players.LocalPlayer
	if Tool.Parent:FindFirstChild("Humanoid") then
		if Input.UserInputType == Enum.UserInputType.MouseButton2 then
			Tool.Handle.Aim:Play()
			script.AimLocal.Disabled = false
			UserInputService.MouseDeltaSensitivity = GunSettings["AimSensitivity"]
			Player.CameraMaxZoomDistance = AimZoom
			Player.CameraMinZoomDistance = AimZoom
			TweenService:Create(plr.Character.Humanoid, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {CameraOffset = Vector3.new(1.4,0,0)}):Play()
			TweenService:Create(workspace.CurrentCamera, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {FieldOfView = 50}):Play()
		end
	end
end)

AimLocal {Enabled when player is holding MouseButton2}

RunService.RenderStepped:Connect(function()
	if plr.Character then
		local rootPart = plr.Character:WaitForChild("HumanoidRootPart")
		if rootPart then
			rootPart.CFrame = CFrame.new(rootPart.CFrame.p, rootPart.CFrame.p + Vector3.new(cam.CFrame.LookVector.X,0,cam.CFrame.LookVector.Z))
		end
	end
		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end)