Cant make a bool equal the opposite of itself?

Im trying to do bool = !bool in a script, is this not part of chaiscript? Ive done something like this:

var myBool = false;
myBool = !myBool;

which seemed to crash?

Edit: Figured it out! turns out because it was on a different thread it didn’t have access to the variable and as a result it crashed. I fixed this with ‘add_global’