Welllll
Firstly, we already have 3 rock crabs scripts (lol), but I guess we'll all welcome new competition
The way I check in my script is much the same to how a human would check:
Walk up to crab
Check if there is a rock crab in the nearest 3x3 square around the player which is fresh
Attack said crab
Check if under attack & rock crab still exists
If no rock crab (NPC) spawns, then refresh
ofcourse there would be timers going on throughout. The only problem with this method is sometimes it refreshes when it doesnt need to if the world lags by over 5 seconds or so, but this rarely happens, so it's not too much of a problemo in my script.
Apaec