AI Pathfinding Help

I am trying to learn pathfinding service, and have done well I feel. However; I wish to know how to make the AI actually follow a set path. Currently, the AI can move from one part to another easily, but does not follow a set path. It just does what it must to get there. Here is the code:

local PFS = game:GetService(‘PathfindingService’)
local zombie = game.Workspace.Zombie
local humanoid = zombie.Humanoid
local destination = game.Workspace.End

local path = PFS:CreatePath()

path:ComputeAsync(zombie.HumanoidRootPart.Position, destination.Position)

local waypoints = path:GetWaypoints()

for _, waypoint in pairs(waypoints) do
local part =“Part”)
part.Shape = “Ball”
part.Material = “Neon”
part.Size =, 0.6, 0.6)
part.Position = waypoint.Position
part.Anchored = true
part.CanCollide = false
part.Parent = game.Workspace


1 Like

Path finding Service singleton does not follow a preset path, it simply finds the shortest path possible if that answers your question. If you want to create a specific path, like in cut scenes, you’ll have to make a path manually if I’m not wrong

1 Like

PathfindingService creates a set of waypoints for you to cycle through to properly move a character from one point or another. If you want to use a preset path, PathfindingService is irrelevant. Simply replace the waypoints generated from the PathfindingService with the waypoints you want to use for your preset path.

If you’re looking to make a repeated path, like a guard for example, patroling an area, you could create your own path following simply creating your own nodes with parts, and have the guards humanoid moveto target the first node and cycle through all nodes until it reaches its last node, and repeat.

1 Like