Help With PathfindingService

So I’ve got a zombie that will wander around until it detects a player (using a ray shot from the zombie’s front) where it then follows the Player’s HumanoidRootPart directly. If the player leaves the zombie’s line of sight, the zombie then switches to using the pathfinding service. This system works great except if I were to lets say, go up some stairs, it’ll be stuck on the 1st method of movement because I’ll still be in its “line of sight” but an entire floor higher. How do I get around this?

As you can see in the picture above, the zombie just goes under it, instead of using the pathfinding service to detect a path via the stairs to get the player. Just to be more clear, I’m asking if someone could explain the logic or a way that I could detect if a player is on another floor, so that I can toggle the path service in the zombie.

try adding a check that checks if the player’s Y coord is plus/minus 1 and if not, pathfind.

IF Raycast does not hit something AND player Y coord is not +- 1 THEN 
   follow player
ELSE
   find the player and pathfind to them

You might just find it easier to use pathfinding for everything, it works really well.

Okay, thanks I’ll try this method out now.

Yeah it would be easier, but I’m trying to save resources this way. I figured using pathfinding to calculate a straight path would be ineffective and wasteful, so I just move the zombie directly towards the player instead of doing that.