My NPC get's the job done, but sometimes he gets stuck around corners trying to cut it too close, and get's stuck.
local p=game:GetService("PathfindingService")
local nodes={}
for _,v in pairs(workspace.Nodes:GetChildren())do
if v.Name=="Node"then
nodes[#nodes+1]=v
end
end
for _,v in pairs(workspace.NPCs:GetChildren())do
wait(.1)
Spawn(function()
while wait()do
local target=nodes[math.random(1,#nodes)]
local path=p:ComputeRawPathAsync(v.Torso.Position,target.Position,500)
if path.Status==Enum.PathStatus.Success then
local points=path:GetPointCoordinates()
for _,point in pairs(points)do
local part,P=workspace:FindPartOnRay(Ray.new(point,Vector3.new(0,-10,0)))
if part then
point=P
points[_]=P
end
end
local br=false
local distance;
for _=1,#points,2 do
local point=points[_]
if br then
break
end
local count=0
repeat
count=count+1
if count>100 then
br=true
break
end
v.Humanoid:MoveTo(points[math.min(#points,_+1)])
if point.Y>=v.Humanoid.Torso.Position.Y-1 then
v.Humanoid.Jump=true
end
distance=(point*Vector3.new(1,0,1)-v.Torso.Position*Vector3.new(1,0,1)).magnitude
wait()
until distance<5
end
else
v.Humanoid:MoveTo(v.Torso.CFrame*Vector3.new(0,0,5))
end
end
end)
end
In other words, is there a way to make this script LESS accurate? (so he won't get stuck around corners or try to go through tight spaces)
UPDATE: Here is a picture: http://s11.postimg.org/603rmqd4j/Screen_Shot_2015_10_26_at_5_14_38_PM.png

2 comments
Do you have a screenshot of how you placed your nodes? I'm not sure how you placed them but maybe you might want to bring the ones near the corners farther out diagonally.
http://s11.postimg.org/603rmqd4j/Screen_Shot_2015_10_26_at_5_14_38_PM.png