ComputeASync not working in pathfinding script

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
  1. What do you want to achieve? Keep it simple and clear!
    Why is it returning nil and how can I fix it?
  2. What is the issue? Include screenshots / videos if possible!
  3. 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.

ComputeAsync always returns nil.
Call GetWaypoints to get the waypoints

I did call GetWaypoints in the script

1 Like

Then It’s possible that the target position is blocked. Try making destination.PrimaryPart cancollide false

1 Like

Changed it to false, that seemed to fix it, thanks

1 Like