Lemme describe this problem then I'll show how I fixed it in my application:
If you use #findCnt to get the number of found items then go through the items one at a time, when the count reaches 0 it actually sets the number to 0 so no action can be taken on that item, because there isn't an item.
So in my detect hidden case, I looked for crates/boxes/chests etc... Lets say I found 6 of them. Now I detect hidden on one of them (6) then ignore it. Now I do the same to (5), (4), (3), (2), and finally (1). After that the count goes to 0.... which isn't a count or an id or anything really... so I fail my detect (no target) and wait 11 seconds.
If you use #findCnt in a script that is fast, like checking resources, getting bandages or something like that, then you have never noticed this because it just flies past it.... but when the count takes time, you can save 11 seconds each cycle.
Here's my fix.... sub reset is just the ignore item reset
set %count #findCnt
.....
if %count = 1
gosub reset
That keeps the #findCnt from going to X which is what it shows after it counts down.
I also put in a safety in my detect loop
if %count = X
return
But it should never be a true statement cause count will get to 1 then reset.