I found that the AI for enemies in a test place i made were causing short lag spikes everytime ComputeASync was called
local function Main(Position, Part:BasePart)
warn("Executted")
if Position then
local Mag = (Root.Position - Position).Magnitude
--local Sight = CheckSight(Part)
if Mag > Range.Value or Part then
local Success = pcall(function() Path:ComputeAsync(Root.Position, Position) end) -- the current assumption is that waypoints are causing high memory usage
local CurrentIndex = 0
warn("Creating path")
if Success and Path and Path.Status == Enum.PathStatus.Success then
warn("Success")
Pathing = true
Blocked = false
if BlockConn then
BlockConn:Disconnect()
BlockConn = nil
end
BlockConn = Path.Blocked:Connect(function(BlockedIndex) -- Make this a one time connection from what i figured
if BlockedIndex >= CurrentIndex then
warn("Lol blocked")
Blocked = true
end
end)
local Points:{PathWaypoint} = Path:GetWaypoints()
if DebugMode then
DebugPath(Points)
end
task.spawn(function()
for i, v in Points do
if not Active.Value or Humanoid:GetState() == Enum.HumanoidStateType.Dead or not Pathing then
break
end
Waypoint = v
CurrentIndex = i
task.wait((16/Humanoid.WalkSpeed)/4)
end
end)
else
warn("Path creation unsuccessful", Path.Status)
--Blocked = true
end
end
end
end
If i remove the pcall in ComputeASync, lag would occur and than this error would follow.
note that this occurs on an empty baseplate
I’ve seen AI freak out like this when an enemy used a laser beam attack that used parts for VFX for i do not know why.
And to prove it was the AI, This is what i got in microprofiler


And this is the navmesh that shows when the game starts lagging
And AI computes every 4 seconds or if the path is blocked or if it sees the target to which it shortens the cooldown to .2 seconds but won’t compute anymore paths
And i do not really know how to replicate it