This script moves the enemy to where I spawned but then just sits there wondering what to do next. I want it to chase the human, any help?
local datpos = plr.HumanoidRootPart.Position
local Path = pfservice:ComputeSmoothPathAsync(workspace.Spawn.Position,datpos + Vector3.new(0,0,3),500)
local Positions = Path:GetPointCoordinates()
math.randomseed(os.time())
local function SpawnEnemy(Type)
local Enemy = Type:Clone()
local Alive = true
Enemy.Parent = game.Workspace.Enemies
Enemy.Humanoid.WalkSpeed = 15
Enemy.HumanoidRootPart.CFrame = workspace.Spawn.CFrame + Vector3.new(math.random(-3,3),0,math.random(-3,3))
local Index = 0
local function NextObjective(Success)
if Success then
Index = Index + 1
end
if Positions[Index] then
Enemy.Humanoid:MoveTo(Positions[Index])
end
end
NextObjective(true)
Enemy.Humanoid.MoveToFinished:connect(function(Reached)
NextObjective(Reached)
end)
end
It runs with no errors but doesn't follow any help?
