Pathfinding - NPC Pushing and getting stuck

The problem doesn’t change unfortunately.

function PathfindToPos(Pos,OverWrite)
	if Pathing == false then
		spawn(function()
			Pathing = true
			local Path = PathfindingService:CreatePath()
			Path:ComputeAsync(HRP.Position,Pos)
			local Waypoints = Path:GetWaypoints()
			
			local TimeOutNum = 2
			local Ting = StopPathfinding
			if Ting == true and OverWrite == true then 
				Ting = false 
			end
			
			if Path.Status == Enum.PathStatus.Success then
				for _, Point in pairs(Waypoints) do
					if not CanSee and Ting == false then
						local CurrentTime = tick()
						repeat wait()
							Humanoid:MoveTo(Point.Position)
							Ting = StopPathfinding 
							if Ting == true and OverWrite == true then 
								Ting = false 
							end
							if (tick() - CurrentTime > TimeOutNum) or Ting then 
								break
							end
						until(HRP.Position-Point.Position).Magnitude<5 or (tick() - CurrentTime > TimeOutNum) or CanSee or Ting
						
						if (tick() - CurrentTime > TimeOutNum) then
							warn("Time out")
						end
						if (tick() - CurrentTime > TimeOutNum) or CanSee then 
							break
						end
					end
				end
			else
				warn("Couldn't find path")
				NormalFollow(Pos)
			end
			Pathing = false
		end)
	end	
end
1 Like