Hello there!
Today I was attempting to try and learn pathfinding.
However, my code doesn’t seem to be working on a blank R15 rig I have.
Here’s is my code:
local Npc = script.Parent
local Humanoid = Npc.Humanoid
local PathfindingService = game:GetService("PathfindingService")
local function getPath(destination)
local path = PathfindingService:CreatePath()
path:ComputeAsync(Npc.HumanoidRootPart.Position, destination.Position)
return path
end
local function walkTo(destination)
local path = getPath(destination)
for index,waypoint in pairs(path:GetWaypoints()) do
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait()
end
end
while true do
walkTo(workspace.destination)
walkTo(workspace.destinatino2)
print("Walking to destination")
end
I’ve checked multiple sites/videos to see what I’ve done wrong. However, nothing seems to be working. If someone could help me with this, that would be great.
Thank you!