Your syntax is incorrect. You have the else statement, but you never asked the if statement, so it doesn't know what to do. How about this:
void button(string &in asEntity)
{
if(GetLocalVarInt("button") != 0) // ON
{
SetLocalVarInt("button", 0); // set to OFF
// Do stuff
}
else
{
SetLocalVarInt("button", 1); // set to ON
// Do stuff
}
}
Here, value 0 (which is default) is treated as OFF and
any other value is treated as ON. That should be safest. I'm also using the Set function rather than the Add function to be more restrictive about the possible states. This is only useful if you have only these 2 states the button can be in - using Add can be useful if you have many different states after each other.