local d,C={},{}local G=0 for W,q in next,workspace.Critters:GetChildren()do G=G+1 if q.PrimaryPart and(character and character.PrimaryPart)then local G=(character.PrimaryPart.Position-q.PrimaryPart.Position).magnitude if G<ACTIVATE_AI_RANGE then table.insert(d,q)else table.insert(C,q)end end if G%10==0 then RS.Heartbeat:Wait()end end Rep.Relay.AI.AIUpdated:FireServer(d,C)elapsed=0
--		debug.profilebegin("AI Offload Loop")
local activate, deactivate = {}, {}
local num = 0
for _, critter in next, workspace.Critters:GetChildren() do
	num = num + 1
	if critter.PrimaryPart and character and character.PrimaryPart then
		local distance = (character.PrimaryPart.Position - critter.PrimaryPart.Position).magnitude

		if distance < ACTIVATE_AI_RANGE then
			table.insert(activate, critter)
		else
			table.insert(deactivate, critter)
		end
	end

	if num % 10 == 0 then
		RS.Heartbeat:Wait()
	end
end
Rep.Relay.AI.AIUpdated:FireServer(activate, deactivate)
elapsed = 0
