ComputeASync returns a nil array instead of an array with waypoints. This code is from the Roblox Dev wiki under the article Pathfinding
local PathfindingService = game:GetService("PathfindingService")
local Zombie = game.Workspace.zombie
local humanoid = Zombie.Humanoid
local destination = game.Workspace.End
local path = PathfindingService:CreatePath()
path:ComputeAsync(Zombie.HumanoidRootPart.Position, destination.PrimaryPart.Position)
local waypoints = path:GetWaypoints()
for index, waypoint in pairs(waypoints) do
local part = Instance.new("Part")
part.Shape = "Ball"
part.Material = "Neon"
part.Size = Vector3.new(0.6, 0.6, 0.6)
part.Position = waypoint.Position
part.Anchored = true
part.CanCollide = false
part.Parent = game.Workspace
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
-
What do you want to achieve? Keep it simple and clear!
Why is it returning nil and how can I fix it? -
What is the issue? Include screenshots / videos if possible!
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried looking on the wiki on ComputeASync and other scripting hubs.