Camera Bobbing Issue

I made a nice camera bobbing script, but I have one last issue

local RS = game:GetService('RunService')

function updatebob(deltatime)
	
	local Player = game.Players.LocalPlayer
	local Character = Player.Character
	
	local Humanoid = Character.Humanoid
	local Camera = workspace.CurrentCamera
	
	if Humanoid.MoveDirection.Magnitude > 0 then
		local OFFSET_BOBBLE_Y = (math.sin(deltatime * 8) * 3)
		local CAMERA_BOBBLE_Z = math.sin(deltatime * 8) * 0.6
		local CAMERA_BOBBLE_Y = math.sin(deltatime * 8) * 0.2
		
		local RESULT_OFFSET = Vector3.new(0,OFFSET_BOBBLE_Y,0)
		local RESULT_CFRAME = CFrame.Angles(CAMERA_BOBBLE_Y,0,CAMERA_BOBBLE_Z)
		
		Camera.CFrame = Camera.CFrame:Lerp(Camera.CFrame * RESULT_CFRAME, .05)
		Humanoid.CameraOffset = Humanoid.CameraOffset:Lerp(RESULT_OFFSET, .05)
	else
		Humanoid.CameraOffset = Humanoid.CameraOffset:Lerp(Vector3.new(0,0,0), .05)
	end
end

RS.RenderStepped:Connect(function(dt)
	updatebob(tick())
end)

And everything works fine, but the camera bobbing goes a little off:

As you can see the cursor goes off the spawn location (I am not moving my mouse at all)
And it also goes to the Y direction of the camera. Can anyone help me?

Try replacing this with time().

The camera system relies on the CFrame of the camera as well, which causes the camera to reset its roll. This, however, does not reset its tilt and yaw.

Using the same CFrame as your basis is more likely to cause an accumulation of inaccurate values to your Camera CFrame.

The only option I see, which unfortunately isn’t exactly direct, is not a fix, but rather a custom camera system, in which you can have the actual angle value of the camera, and a separate angle value that is only used as an offset for the bobble effect, and in no way affects the actual angle.