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.