hello I know whats wrong and I know the solution. I just dont know how to do the solution. Bassically I remember there being some sort of path:Wait() or path.completed:Wait() so that it waits for the npc to get to the final path but I forgot its name.

Heres the code:

```
task.wait(3)
print("going")
local pathfindingService = game:GetService("PathfindingService")
local basePos = workspace.Base.Position
local starting = script.Parent:GetPivot().Position
local direction = (basePos - starting).Unit -- gets the direction vector from NPC to target
local base = game.Workspace.Base
local baseSize = base.Size
-- Calculate a new ending position that is offset from the center of the base
local endingOffset = Vector3.new(0, 0, 0)
if starting.X < base.Position.X then
endingOffset = Vector3.new(baseSize.X/2 + 10, 0, endingOffset.Z)
end
if starting.X > base.Position.X then
endingOffset = Vector3.new(-(baseSize.X/2 + 10), 0, endingOffset.Z)
end
if starting.Z < base.Position.Z then
endingOffset = Vector3.new(endingOffset.X, 0, baseSize.Z/2 + 10)
end
if starting.Z > base.Position.Z then
endingOffset = Vector3.new(endingOffset.X, 0, -(baseSize.Z/2 + 10))
end
local ending = base.Position + endingOffset * direction
-- Compute the path to the new ending position
local path = pathfindingService:CreatePath()
task.wait(1)
path:ComputeAsync(starting, ending)
for i, waypoint in ipairs(path:GetWaypoints()) do
local X = math.floor(waypoint.Position.X / 5) * 5
local Y = math.floor(waypoint.Position.Y / 5) * 5
local Z = math.floor(waypoint.Position.Z / 5) * 5
local FinalPos = Vector3.new(X,Y,Z)
script.Parent.Humanoid:MoveTo(FinalPos)
print("moving to")
end
```