Pathfindingservice gets stuck on walls

hello devs,

ive been working on a pathfinding system using a humanoid, but Ive run into an issue. When the humanoid falls and needs to reach a higher path, it keeps jumping into the wall repeatedly instead of finding a valid path to go to.

ive tried several solutions, like enabling jumping only when necessary, adjusting the jump height, and tweaking the pathfinding behavior, but nothing seems to work.

ive linked a video to better illustrate the problem. Any help would be greatly appreciated.

Also, here’s the script:

local noob = workspace:WaitForChild("Noob")
local noobRoot = noob:WaitForChild("HumanoidRootPart")
local humanoid = noob:WaitForChild("Humanoid")
local pathService = game:GetService("PathfindingService")

-- Function to move the noob
local function followPlayer(realPlr)
	local char = realPlr.Character or realPlr.CharacterAdded:Wait()
	local root = char:FindFirstChild("HumanoidRootPart")

	-- Create a path
	local path = pathService:CreatePath({
		AgentCanClimb = false,
		AgentRadius = 0.5,
		AgentHeight = 0.1,
		AgentCanJump = true,
		AgentMaxSlope = 999,
		AgentJumpHeight = 0.01,
		WaypointSpacing = 2
	})
	
	-- Compute the path
	path:ComputeAsync(noobRoot.Position, root.Position)
	
	-- Check if the path is valid
	if path.Status == Enum.PathStatus.Success then
		
		local waypoints = path:GetWaypoints()
		for i, waypoint in ipairs(waypoints) do
			
			local new = Instance.new("Part")
			new.Anchored = true
			new.Parent = workspace
			new.Size = Vector3.new(1, 1, 1)
			new.Position = waypoint.Position
			new.CanCollide = false
		
			task.delay(0.5, function()
				if new and new.Parent then
					new:Destroy()
				end
			end)
			
			-- Jump when needed
			if waypoint.Action == Enum.PathWaypointAction.Jump then
				humanoid.Jump = true
			end

			humanoid:MoveTo(waypoint.Position)
		end
	else
		warn("something went wrong")
	end
end


game.Players.PlayerAdded:Connect(function(realPlr)
	while task.wait() do
		followPlayer(realPlr)
	end
end)