хз. я лично не нашел ошибок в коде.
ето, попробуй его рекурсией:
function FreeChild(ent,name$)
local i
if countchildren(ent)>0
for i=1 to countchildren(ent)
FreeChild(getchild(ent,i),name$)
Next
else
if instr(lower(entityname(ent)),lower(name)) then freeentity ent
EndIf
End Function
за работоспособность не отвечаю, не пороверял, но в принципе должно работать