I have this pathfinding script and for some reason it only works when the rig is very close to the target. Otherwise, it just warns what I wrote. Is there any was to change the range?
local pathFindingService = game:GetService("PathfindingService")
local zombie = workspace.Rig
local hum = zombie:WaitForChild("Humanoid")
local EndDest = workspace.refPart
local path = pathFindingService:CreatePath({
AgentRadius = 3,
AgentHeight = 5,
AgentCanJump = false,
AgentCanClimb = false,
Costs = {
water = 100
}
})
path:ComputeAsync(zombie.HumanoidRootPart.Position, EndDest.Position)
if path.Status == Enum.PathStatus.Success then
local nodes = path:GetWaypoints()
for i, v in pairs(nodes) do
print("creating")
local node = Instance.new("Part", workspace)
node.Size = Vector3.new(1,1,1)
node.Anchored = true
node.CanCollide = false
node.Position = v.Position
end
else
warn("Failed!")
end