Mouselock poppercam help (Camera collisions)

I’ve really been frustrated on trying to make a 100% working poppercam, since Roblox’s clips through parts with mouse lock enabled.

I’ve been stuck for about 5 hours trying to get it 100%. Basically, I’m at 95%. Currently mine pretty much works but no matter what, it slightly misses collisions if you line it up right. I’d say like exactly 90 degrees.

Does anyone know how to fix this? Moving the raycast direction point to the left and right doesn’t seem to work. Plus, it doesn’t really look as smooth as the default roblox one because the orientation doesn’t stay the same.

What I’m talking about:


local function collisionFunc(part)
	return (part.CanCollide and part.Transparency < 1 and not part:FindFirstAncestor("Cars") and not part:IsDescendantOf(char) and not part.Parent:FindFirstChild("Humanoid"))

local function cast(ray)
	local destination = ray.Origin + ray.Direction
	-- draw multiple raycasts concatenated to each other until no hit / valid hit found
	while ray.Direction.magnitude > 0.001 do
		local part, pos, norm, mat = workspace:FindPartOnRayWithIgnoreList(ray, {char})
		if not part or collisionFunc(part) then
			return part, pos, norm, mat
		local start = pos + ray.Direction.Unit * 0.001
		ray =, destination - start)

	local camCF = camera.CFrame
	local ray =, (camCF.p - head.CFrame.p))
	local _, _, _, xx, yx, zx, xy, yy, zy, xz, yz, zz = camCF:GetComponents()
	local hit, pos, norm = cast(ray)
	if hit then 
		camera.CFrame =, pos.Y, pos.Z, xx, yx, zx, xy, yy, zy, xz, yz, zz)


Any help is extremely appreciated. This has been stumping me for too long, I feel like I’m not getting anything done and going nowhere. My problem is that it doesn’t pick up the collision if you line it up precisely.