I am trying to make an NPC move around and pick up parts around the map using Roblox's pathfinding service. My troubles arise whenever one of the parts is higher elevated than the npc, and when that happens the path doesn't generate at all. I have tried many solutions to fix this and currently nothing has worked. If anyone has some suggestions please tell me, and if you think I should just make my own pathfinding script, then please tell me how I should go about doing it.
while wait() do local Path = PathfindingService:ComputeRawPathAsync(Part0.Position, Part1.Position, 500) local Points = Path:GetPointCoordinates() for i,v in pairs(Points) do local Part = Instance.new("Part", workspace) Part.Anchored = true Part.Position = v Part.Transparency = 0 Part.Size = Vector3.new(.5,.5,.5) Part.Color = Color3.fromRGB(255,0,0) game.Debris:AddItem(Part, .1) end end
The reason why it won't work is because your using a very deprecated version of PathfindingService and roblox refuses to run it. To keep up to date with the new Pathfinding, here is your script redone with the modern API.
while wait() do local Path = PathfindingService:FindPathAsync(Part0.Position, Part1.Position) local Points = Path:GetWayPoints() for i,v in pairs(Points) do local Part = Instance.new("Part") part.Parent = workspace Part.Anchored = true Part.Position = v Part.Transparency = 0 Part.Size = Vector3.new(.5,.5,.5) Part.Color = Color3.fromRGB(255,0,0) game.Debris:AddItem(Part, .1) end end