[Solved]Manage On Off button

Hello all,
I have a question: I want to create a switch button.
My targhet is to press it the first time ancd the variable value became 1 (ON) at next click 0 (OFF9 and so on.

The problem is that I suppose it do all every frame so when I press the button:
the first command is:
if value = ON the value = OFF
if value = OFF the value = ON
so it is every time ON.

The correct code shoud if
if variable = On
then variable = Off
ELSE variable = On

This is the code:


Trigger once while true condition

No, it doesn’t work. I tried to put Once on the first box but not. So I tried alll the combination but it does not work.
I tried to insert the ToDo variable but nothing.
I tried to change from Down to Release left button action but it works only the first time

It’ incredible !!!

You don’t need the variable Todo. You have a little problem that is evident. Look at your actions in the 2 events. Specifically at setting the on off variable. You set it both time to 1, while you should set it to 0 the first time.

for example:

You are right but insert zero wasn’t the correct solution.

WOW, it works !!! Thanks a lot !!!