Using testfor to find a player who has left a zone (1.12.2)

I have Minecraft 1.12.2 (for Java Editon), and I'm trying to make a contraption that will keep spectators of certain levels within a certain area. I already have something that works, but it only works with one player. My command is show below:

/testfor @a[x=79,y=53,z=-102,dx=25,dy=25,dz=25,m=3]

The command checks if there is anyone within the zone. However, it doesn't check which players leaves the zone, but only the last person who left it. I need a command that will check if any spectators leave the zone. There are also multiple levels, 12 to be exact. Each level will need its own spectator zone and I don't want them to interfere with each other. I have tried /testfor @a[!x=79,!y=53,!z=-102,dx=25,dy=25,dz=25,m=3] but it doesnt work. Any help would be appreciated!


First, create a dummy scoreboard objective. I've called it spectatorInBounds here.

/scoreboard objectives add spectatorInBounds dummy

Once you have that, make a repeating command block with the command:

/scoreboard players reset @a spectatorInBounds

Then, for each 'zone' you have, add a chain command block with the command:

/scoreboard players set @a[x=X,y=Y,z=Z,dx=DX,dy=DY,dz=DZ,m=3] spectatorInBounds 1

Finally, to check for a spectator that is out of bounds:

/execute @a[score_spectatorInBounds=0] ~ ~ ~ [. . .]