How to change a GUI button texture through scripting

Our GUI has several buttons on the layout. What I'm trying to do is change the texture of the button based on whether or not a specific boolean is true or not. I've looked through answers and the scripting reference, but haven't found anything that looks like it'd work.

Basically it'd be something like

if (ThirdPersonController.gasMask = true) change texture else use original/normal texture.

That's what GUI Skins are made for.

You can set up textures for the states of buttons: On Normal, On Hover, On Active and On Focused and a lot more.