=Overview=
The script is an Ai, it follows mobs,i am trying to implicate pathfinding to it, I've succesfully made it so that it makes a path out of parts in the 'Pathfinding' way to the target.
**~=Problem=~ ** The script find nearest Npc and goes towards them like its saposed to, but it does not take the pathfinding path
while wait() do
local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
local magnitude = (script.Parent.HumanoidRootPart.Position - target.Position).magnitude
print('WENUS')
if magnitude < 5 and deb == false then
deb = true
script.Parent.Humanoid.WalkSpeed = 0
script.Parent.Attacking.Value = true
wait(.5)
script.Parent.Humanoid.WalkSpeed = script.Parent.Settings.MoveSpeed.Value
deb = false
else
while true do
path = game:GetService ("PathfindingService"):ComputeRawPathAsync (script.Parent.Torso.Position,target.Position,200)
points = path:GetPointCoordinates()
game.Workspace.Points:ClearAllChildren()
for p = 1, #points do
part = Instance.new("Part")
part.FormFactor = Enum.FormFactor.Symmetric
part.Size = Vector3.new(1,1,1)
part.CanCollide = false
part.Position = points[p]
part.Anchored = true
part.BrickColor = BrickColor.DarkGray()
--part.Transparency = 0
part.Parent = game.Workspace.Points
end
script.Parent.Humanoid:MoveTo(target.Position,target)
--also tried script.Parent.Humanoid:MoveTo(part.Position,part)
wait(0.5)
end
end
end
end

2 comments
Perhaps the range is too short?
no