humanoid.MoveToFinished:Wait() doesn't work normally

i want to make npc wihich moves to waypoint
but MoveToFinished:Wait() doesn’t fire properly
script prints text when npc is going
i tried SetOwnerNetwork(nil) but it doesn’t work
like this:
script.Parent.HumanoidRootPart:SetNetworkOwner(nil)

here is my main script:

local finish = game.Workspace.FishingZone —Finish part
local dummy = script.Parent
local humanoid = dummy.Humanoid

local PathfindingService = game:GetService(“PathfindingService”)
local path = PathfindingService:CreatePath()

path:ComputeAsync(dummy.Torso.Position, finish.Position)

– Get the path waypoints

local waypoints = path:GetWaypoints()

for _, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
print(“finished”)
end

Looking at the script I assume it is printing “finished” constantly while the npc is moving?
Since it is a loop every time the npc goes from one waypoint to another it would print “finished”, which will repeat many times since well, there are a lot of waypoints.
If you want it to print after the npc finishes its pathfinding just put the print command after the loop.

for _, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
print(“finished”)
--loops yield
1 Like

uh i forgot to do that thanks )

1 Like