Turn Off int using Boolean

Hello Everyone, sorry i’m always ask a question in unityanswers

Why does everytime i want to turn off the int using boolean, debug says “cannot convert int to boolean”. How do i turn off the int? it’s so annoying

and this is the example of my script
currentMenuItem is Int, and menuToggle is Bool

function Update (){
    	
    	if(!menuToggle){
    		menuItems[currentMenuItem].OnSelected(false);
    		if(settingsToggle){
    			currentMenuItem = 3; //i've got Array index is out of range.
    		}
    
    	}
    
    	if(!settingsToggle){
    		menuItemz[currentMenuItemz].OnSelected(false);
    	}
    
    }

and this is the video - YouTube

thank you very much for the reply. I really need this

Well, if you’re trying to convert a number into a ‘true or false’ value, that’s going to happen. I’m afraid from your code, it’s not especially clear what’s going on here! I con’t know what menuItems is, or where exactly you are trying to do what you are trying to do.

The ‘Array index out of range’ exception happens if you try to access a variable which is either smaller than zero, or greater than the highest index in the array. An array is indexed from 0 - (size - 1)- if your array is 3 long, the first one will be indexed ‘0’, and the last one will be indexed ‘2’. It’s possible that this is what is confusing you here.

I’m afraid that video you posted along with the question sheds absolutely no light on what the problem might be.

Basically, you can’t ‘deactivate’ an int. What are you trying to do, stop the number from existing? That does’t really make any sense. I’m sure what you’re trying to do is possible, but the method you are chasing here is a dead end. Please explain yourself a bit better, and I’m sure someone’ll be able to help you find a better way.