so what i actually wanna know is that, is there even a more optimized way on
detecting nearby humanoids? like no performance huge drop or server lags
because the humanoid detection system i’ve been creating are laggy. i don’t know how anime fighting simulator x made theirs not laggy but i wanna know something like that how to create im not asking for a code im just asking how would i be able to create such humanoid detection system like AFSX.
the mob moves around and when there’s an enemy near it’ll go to the nearest target and starts attacking, i made one but when there is 10 of mobs it pretty much lags i don’t know why but i’d like to know how to make out. either like AFSX or BLOX FRUITS!
it just lags when there’s a total of 10 mobs.
here’s an example of my code:
– server
local function getnearestentity()
for i,v in pairs(workspace:GetDescendants()) do
-- stuff then do return if its the perfect target.
end
end
while script do
local mob = getnearestentity()
-- some function of attacking
task.wait(0.1)
end
thanks, this kinda helped but one more question.
does it lag when there is around 20+ mobs like im going to loop through using collectionservice with entities tagged like that? only humanoid tho.
Luau is pretty fast, so I expect it can even loop through 500+ entities with no performance overhead, considering that you don’t perform any heavylifting calculations or yield during iterations.