Need Some Help Making A Custom ShiftLock

Like The Title Said, I Need Help With My ShiftLock Script Tho The Main Problem Is The Humanoid.CameraOffset For Some Reason every time I Set A Value To The X-Axis The Camera Sometime Shake When Rotating But It Becomes Smooth When I Set The X-Axis To 0

local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local Cam = workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local ShiftLock = Instance.new("BoolValue", plr)
ShiftLock.Name = "ShiftLock"
ShiftLock.Value = false

local Runservice = game:GetService("RunService")

Runservice.RenderStepped:Connect(function(dt)
	
	local Character = plr.Character or plr.CharacterAdded:Wait()
	if Character then
		if Character:FindFirstChild("HumanoidRootPart") and Character:FindFirstChild("Humanoid") then
			if ShiftLock.Value == false then 
				Character.Humanoid.AutoRotate = true
				if UIS.MouseBehavior == Enum.MouseBehavior.LockCenter then
					UIS.MouseBehavior = Enum.MouseBehavior.Default
					Character.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
				end

			else
				Character.Humanoid.AutoRotate = false
				if UIS.MouseBehavior == Enum.MouseBehavior.Default then
					UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
					Character.Humanoid.CameraOffset = Vector3.new(1, 1, 0)
				end
				local HRP = Character.HumanoidRootPart
				
				local x,y,z = Cam.CFrame:ToOrientation()
				HRP.CFrame = CFrame.new(HRP.Position) * CFrame.Angles(0, y, 0)
			end
			
		end
	end
end)

Here’s When The Camera Offset Is 1.1.0

And Here’s When It’s 0,2,0

You could try -1, 0, 0 then??
It’s that easy whatsoever

Note:
X - Left and Right Pos
Y - Up and down pos
Z - Left and Right Pos 2

nope didn’t work if I set x or z to anything other than 0 then the camera will shake when rotating

Hm, then you could use loops for camera moving, i don’t know why that happens