How to prevent camera clipping walls in FP

I dont know what to do, i dont undestrand

use this

local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function(step)
	if char:FindFirstChild("Head") then
		local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
		local ignoreList = char:GetChildren()

		local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)

		if hit then
			char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
		else
			char.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
		end
	end
end)

i tried but it bugs (example: on ladder)


and this how looks this