I am making a piggy form of game and my Ai pathfinding script is not working any way I can fix it? Here the script:
local Scientist = script.Parent
local humanoid = Scientist.Humanoid
local PathfindingService = game:GetService ("PathfindingService")
local function getPath(destination)
local path = PathfindingService:CreatePath()
path:ComputeAsync(Scientist.HumanoidRootPart, 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.destination2)
end

2 comments
it would be pretty nice if you could tell us the error and which line it's on
its actually saying there is no error but he is not moving.