Common problem with viewbobbing glitching character - cant Get a working a viewbob

been looking for a working viewbob for a while and cant find one
this is what happens when you go in first person, the viewbob moves the player or something



ive looked everywhere on dev fourm and toolbox and this happens in alot of scripts
the script am using is from toolbox but it happens in pretty much any viewbob script you can find

--// Originally Coded By: RobloxMinecraftDK
--// Professionally Optimized By: iGottic

--// This script should be placed as a decendant to StarterGui for it to properly work.

local GENERAL_DAMPING = 1 -- Higher number equals less bob
local TILT_DAMPING = 2 -- Higher number equals less tilt
local OFFSET_DAMPING = 0.9 -- Higher number equals less camera offset bobbing

--// ------------------------------- //--
--// Don't edit anything below here! //--
--// ------------------------------- //--

local camera = game.Workspace.CurrentCamera
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local Z = 0
local damping = (character.Humanoid.WalkSpeed / 2) * GENERAL_DAMPING
local PI = 3.1415926
local tick = PI / 2
local running = false
local strafing = false

humanoid.Strafing:Connect(function(bool)
	strafing = bool
end)

humanoid.Jumping:Connect(function()
	running = false
end)

humanoid.Swimming:Connect(function()
	running = false
end)

humanoid.Running:Connect(function(speed)
	if speed > 0.1 then
		running = true
	else
		running = false
	end
end)

local function mix(par1, par2, factor)
	return par2 + (par1 - par2) * factor
end

while true do
	game:GetService("RunService").RenderStepped:Wait()
	
	fps = (camera.CFrame.p - character.Head.Position).Magnitude
	
	if fps < 0.52 then
		Z = 1
	else
		Z = 0
	end
	
	if running == true and strafing == false then
		tick = tick + humanoid.WalkSpeed / 92
	else
		if tick > 0 and tick < PI / 2 then
			tick = mix(tick, PI / 2, 0.9)
		end
		if tick > PI / 2 and tick < PI then
			tick = mix(tick, PI / 2, 0.9)
		end
		if tick > PI and tick < PI * 1.5 then
			tick = mix(tick, PI * 1.5, 0.9)
		end
		if tick > PI * 1.5 and tick < PI * 2 then
			tick = mix(tick, PI * 1.5, 0.9)
		end
	end
	
	if tick >= PI * 2 then
		tick = 0
	end	
	
	camera.CFrame = camera.CFrame * 
		CFrame.new(math.cos(tick) / damping * OFFSET_DAMPING, math.sin(tick * 2) / (damping * 2 * OFFSET_DAMPING), Z) * 
		CFrame.Angles(0, 0, math.sin(tick - PI * 1.5) / (damping * 15 * TILT_DAMPING)) --Set camera CFrame
end

Is there any fixes for this problem?
to not make it shake while its not in first person?