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
It's because you are adding that Vector3 on lines 19 and 25. Honestly I have no idea why you have those there but if you remove all 3 occurrences then it will work.