while true do
v = game.Workspace.target
path = game:GetService("PathfindingService"):ComputeSmoothPathAsync(script.Parent.Torso.Position, game.Workspace.target.Position, 500)
points= path:GetPointCoordinates()
if path.Status.Name == "Success" then
game.Workspace.Points:ClearAllChildren()
for p = 1, #points do
part = Instance.new("Part")
part.CanCollide = false
part.Size = Vector3.new(1,1,1)
part.Position = points[p]
part.Anchored = true
part.BrickColor = BrickColor.Black()
part.Parent = game.Workspace.Points
end
for i=1,10 do
local part,point=workspace:FindPartOnRay(Ray.new(points[math.min(#points,i)],Vector3.new(0,-10,0)))
local part,point2=workspace:FindPartOnRay(Ray.new(points[math.min(#points,i+1)],Vector3.new(0,-10,0)))
local count=0
while math.min((point2-v.Position).magnitude,(point*Vector3.new(1,0,1)-v.Position*Vector3.new(1,0,1)).magnitude)>3 and count<50 do
count=count+1
script.Parent:FindFirstChild("Humanoid"):MoveTo(point2)
if workspace:FindPartOnRay(Ray.new(v.Position,CFrame.new(v.Position*Vector3.new(1,0,1),point2*Vector3.new(1,0,1)).lookVector*4))then
script.Parent:FindFirstChild("Humanoid"):MoveTo(point)
end
end
end
end
wait(0.1)
end
i want to make a pathfinding NPC that goes to its target in workspace i tried to make this script above but this script moves the npc but does not make it follow the points. basically it doesnt follow the path the computer computes for it. please help me.

2 comments
Hopefully this helped!!
ty