Simple pathfinding script does not work: no errors in output, and prints all

Sorry if this is a dumb question, but i’ve only actually started to use pathfinding for npcs. However, the code i wrote is almost identical to the developer hub’s sample code. Here is is:

local npc = workspace.npc
local PathfindingService = game:GetService("PathfindingService")
local humanoid = npc.Humanoid
local destination = workspace.Part.Position
local path = PathfindingService:CreatePath()
local waypoints

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

waypoints = path:GetWaypoints()

for _, way_points in pairs(waypoints) do
	local part = Instance.new("Part")
	part.Shape = "Ball"
	part.Material = "Neon" -- copied from devhub cuz i was lazy
	part.Size = Vector3.new(0.6, 0.6, 0.6)
	part.Position = way_points.Position
	part.Anchored = true
	part.CanCollide = false
	part.Parent = game.Workspace
	wait(10)
	humanoid:MoveTo(way_points.Position)
	humanoid.MoveToFinished:Wait()
	print("finished!")
end

The character does not move yet it prints “finished” in the output. Is this an issue outside of the script? The character does not move at all.

1 Like

Please make sure the HumanoidRootPart is not anchored

HumanoidRootPart is not anchored.

Why is there a wait(10) ? If I copy your code and remove that part, it works perfectly fine.

Works, a stupid error on my part.

The npc was more glitchier then usual so i might have to make a different pathfinding ai walking. thanks again.