I was just creating a pathfinding module for myself and tried it out, but the for loop inside of it did not even run. Does anyone know why. There are no errors, here is the script:
function PathFinding:StartPath(CurrentStage, CPUSpawnPos, End)
local PathFindingService = game:GetService('PathfindingService')
local pathToMoveOn = PathFindingService:CreatePath()
local AI = game.Workspace.AllStages[CurrentStage].Robot
local humanoid = AI.Humanoid
print("Running Path")
local pathToMoveOn = PathFindingService:CreatePath()
pathToMoveOn:ComputeAsync(AI.HumanoidRootPart.Position, End)
local wayPoints = pathToMoveOn:GetWaypoints()
for _, WayPoint in pairs(wayPoints) do
if WayPoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
local Sphere = Instance.new("Part")
Sphere.Shape = "Ball"
Sphere.Material = "Neon"
Sphere.Size = Vector3.new(0.6,0.6,0.6)
Sphere.Anchored = true
Sphere.CanCollide = false
Sphere.Parent = workspace
Sphere.Position = WayPoint.Position + Vector3.new(0,3,0)
humanoid:MoveTo(WayPoint.Position)
humanoid.MoveToFinished:Wait()
else
humanoid:ChangeState(Enum.HumanoidStateType.Running)
local Sphere = Instance.new("Part")
Sphere.Shape = "Ball"
Sphere.Material = "Neon"
Sphere.Size = Vector3.new(0.6,0.6,0.6)
Sphere.Anchored = true
Sphere.CanCollide = false
Sphere.Parent = workspace
Sphere.Position = WayPoint.Position + Vector3.new(0,3,0)
humanoid:MoveTo(WayPoint.Position)
humanoid.MoveToFinished:Wait()
end
end
end
Edit: The Parts I was creating were just to see if the loop was actually running.