So im new to using the pathfinding service and I wrote this code trying to get my npc to walk to the wall block. However, for some reason it isnt working and there isnt any error coding in the output. If anyone could figure it out it would be greatly appreciated! Code is below, thank you!
local PathfindingService = game:GetService("PathfindingService")
local humanoid = script.Parent:WaitForChild("Humanoid")
local npc = script.Parent:WaitForChild("HumanoidRootPart")
local target = game.Workspace.Wall
local path = PathfindingService:CreatePath()
path:ComputeAsync(npc.Position, target.Position)
local waypoints = path:GetWaypoints()
for i, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end

1 comment
Quick guess: everything's working except MoveToFinished might not fire if the waypoint position is too close? Use
printstatements to find out!