Help with boolean variables

What I’m trying to do is click on the red square with the mouse and have a check mark appear, then click it again, the check mark goes away. The variable is redClicked, and the values are true/false. It works fine when I use the keyboard (t for true, f for false), but not when I use the mouse. I’m sure it’s something simple that I’m missing, please have a look at the code and tell me where I’m going wrong, thank you!

When you’re using the mouse, it’s rapidly changing back and forth between “true” and false". It works on the keyboard because you have different keys.

You want to use a toggle switch variable. Here’s a tutorial around it: Toggle simple switch

1 Like

Thank you so much, I’ll report back when I get it working!

Did you try doing “mouse button released” instead of “mouse button down”?

1 Like

I think you need to change the event order, try

– Check if mouse is on RedLight
– Touch or Left mouse
– Trigger Once
Inside as subevent -----
--------- The text of variable redClicked of RedLight = “true”

Another approuch is to add another global variable to control like
Global RedChecked = 0/1
So if RedChecked = 0 && redClicked = “false”
– Do your stuff

1 Like

Thanks for all the answers, it works just fine using integers as the variable’s value; 0 for false, 1 for true.
See the event sheet below.

However, I would still like to know how to use a string for the value. For example, lets say that instead of just two states (checked or not), the box cycles through five different colors. Instead of calling those colors/states 0-4, maybe I want to be able to call them red, yellow, green, etc.