How to use pathfindingservice on a npc that uses sidewalks(specific part) only

Hello. Im wondering if there is a way that NPC would find a path with pathfindingservice to a position but the NPCs should only use sidewalks(specific parts) only

Greetings!

I might be wrong, but if I were to make that I would get all pathways to one folder or name every sideway you wanna use to same one name.

Later I would make ray to detect if part is named same. If yes I would get position of it and will make it a path for NPC.

I might make a simple code for you in some minutes.

Sorry for my lack of English.

1 Like

If you won’t be able to find a better method to do it, I suggest this one (but it’s not recommended!): Ignoring parts with PathfindingService - #8 by Hexcede

Well thanks but im a bit new to pathfindingservice could you tell me some example?

Let me make an example.

You want your Model to go from point A to point B.

Imagine a rig, you place it somewhere and you place some part let’s name it Finish.

I made example script,

local PathService = game:GetService("PathfindingService") -- This gets and initiates the service

wait(5)
local HumanRoot = script.Parent:WaitForChild("HumanoidRootPart")
local Human = script.Parent:WaitForChild("Humanoid")

local Path = PathService:CreatePath() -- This creates a path object that will be part of the script
Path:ComputeAsync(HumanRoot.Position, workspace.Finish.Position) --[[
This creates the "path" that will the Human follow,
Argument #1 "HumanRoot.Position" In this insert the position where it starts (Point A)
Argument #2 "workspace.Finish.Position In this insert the position where it will end (Point B)
]]--
local Waypoints = Path:GetWaypoints() -- This gets the ways the service creates, be carreful since the service sometimes make the path ACROSS the parts that are around the path. If you will want I might give you one that will make the humanoid go around the parts and not go straight to them.
if(Path.Status == Enum.PathStatus.Success) then -- This checks if the path is successfuly made.
	for i, v in ipairs(Waypoints) do -- Since the waypoints are ArrayLike object you'll need to have this stuff so the human goes straight the calculated path. "ipairs" here is to check stop if error is made.
		wait()
		Human:MoveTo(v.Position)
		Human.MoveToFinished:Wait() 
		if(v.Action == Enum.PathWaypointAction.Jump) then -- This checks if the waypoint is above the height and needs the human to jump if the path cannot be accessed normaly.
			wait()
			Human.Jump = true
		end
	end
end

I hope this atleast helps you for now.

It should look like this,

Well I know how to use pathfinding services I don’t know how to make it to use specific parts :confused: