I have created a little script that will restart the path of my AI every second so that it will automatically correct itself if it gets stuck, and also so that it can switch between targets if one gets closer than the current target (that part's not coded yet). So, here's the issue. It still gets stuck on corners, which is fine, except that the new paths don't avoid the wall/corner it's stuck on, it just continues to attempt to run through them. Why?
local tic = 0
local pathfindingservice = game:GetService("PathfindingService")
local pathfindingparameters = {
["AgentHeight"] = 6.8,
["AgentRadius"] = 3,
["AgentCanJump"] = false
}
local corotine = coroutine.create(function()
while wait(1) do
tic = tic + 1
end
end)
coroutine.resume(corotine)
function createpath(scploc,targetloc)
local path = pathfindingservice:CreatePath(pathfindingparameters)
path:ComputeAsync((scploc + Vector3.new(-500,0,0)), (targetloc + Vector3.new(-500,0,0)))
return path
end
while mode.Value == 3 do
for index, waypoint in pairs (createpath(hrp.Position, game.Workspace.TARGET.Position):GetWaypoints()) do
human:MoveTo(waypoint.Position + Vector3.new(500,0,0))
human.MoveToFinished:wait()
if tic >= 1 then
tic = 0
break
end
end
end

1 comment
I figured it out, and it wasn't actually this issue. This was 100% intentional, because I had a second maze in that spot. I'm doing that so my AI can pathfind through doors on the map. (That secondary map 500 blocks away has no doors, so the pathfinding happens there and then is translated back over, and the AI walks around ignoring the doors)