An NPC who walks to the nearest point to the player if he has not found a way to him

I’m trying to set up my NPC to walk up to the player, but what if the player is higher up and the NPC can’t get there because the waypoints aren’t given. Is there any way to check the place below for the departure of the free position of not the player, but below him relative to where he stands now?

My thoughts:
Perhaps it’s worth doing several pathfinding along the Y vector, counting down 5 at a time and choosing the nearest one?

local PathfindingService = game:GetService("PathfindingService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")

local path = PathfindingService:CreatePath()

local player = Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection

local function followPath(destination)
	-- Compute the path
	local success, errorMessage = pcall(function()
		path:ComputeAsync(character.PrimaryPart.Position, destination)
	end)

	if success and path.Status == Enum.PathStatus.Success then
		-- Get the path waypoints
		waypoints = path:GetWaypoints()
	end
end
wait(5)
followPath(game.Players.rikisamejima.Character.HumanoidRootPart.Position)