Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why Wont This Pathfind Script Work?

Asked by
Benqazx 108
9 years ago
01local p=game:GetService("PathfindingService")
02 
03local target = script.Parent.Target.Value.Torso
04local v = script.Parent
05local parts = script.Parent:GetChildren()
06    local path=p:ComputeRawPathAsync(v.Torso.Position,target.Position,500)
07        if(v.Torso.Position-target.Position).magnitude<4 and target~=v.Torso then
08            target:Destroy()
09        end
10        local points=path:GetPointCoordinates()
11        if #points>1 then
12            for i=1,10 do
13                local part,point=workspace:FindPartOnRay(Ray.new(points[math.min(#points,i)],Vector3.new(0,-10,0)))
14                local part,point2=workspace:FindPartOnRay(Ray.new(points[math.min(#points,i+1)],Vector3.new(0,-10,0)))
15                local count=0
View all 33 lines...

this is a pathfinding script. i want this to make the the NPC that has this script in him to follow the target. but it doesnt follow him. it moves to 1 place then stops there. it doesnt follow the player right. please can you help me with this.

Answer this question