NPC doesn't go to destination with

I need some help on pathfinding, idk why it won’t go forward. It’s supposed to go to towards the brick but nothing happens.

local PathfindingService = game:GetService("PathfindingService")
local Path = PathfindingService:CreatePath()
local rs = game:GetService("ReplicatedStorage")

Path:ComputeAsync(script.Parent.HumanoidRootPart.Position, workspace.h.Position)
local Waypoints = Path:GetWaypoints()

for i, waypoint in pairs(Waypoints) do
	script.Parent.Humanoid:MoveTo(waypoint.Position)
	script.Parent.Humanoid.MoveToFinished:Connect(function()
		print("Done")
	end)
end

Make sure to check if any part of the dummy is anchored, I believe the HumanoidRootPart can be anchored which causes the NPC to move in place.

You can add this at the start of your code:

for _, bodyPart in pairs(script.Parent:GetChildren()) do
   if not bodyPart:IsA("BasePart") then continue end
   bodyPart.Anchored = false
end

Try removing the local Waypoints = Path:GetWaypoints() and change the for i, waypoint in pairs(Waypoints) do into for i, waypoint in pairs(Path:GetWaypoints()) do and add script.Parent.Humanoid.MoveToFinished:Wait() above script.Parent.Humanoid.MoveToFinished:Connect(function()

Oh my god thank you so much :sob::pray::pray:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.