Try this alteration
on @*:join:#:{
if $+(%,autovoice,.,$chan) { .mode # +v $nick }
on 1000:text:.av:#:{
set $+(%,autovoice,.,$chan) $iif(!$($+(%,autovoice,.,$chan),2),$true,$false)
.notice $nick Auto-Voice for $chan is $iif(!$($+(%,autovoice,.,$chan),2),on,off)

The above code uses the .av text as a simple on/off switch.
If the auto-voice is on and someone with level 1000 uses the .av command then it turns off, and vice-versa

I can see the following possibilities with your original code.
1) the fact that to set the Voice mode one has to have ops, and you don't check for that.
2) No one has a user level of 1000 to be able to turn the auto-voice on or off.
NOTE: This last item will also cause my code to fail.