[SOLVED] Toggle Text on Key Press

The idea is:
On load - text is “ON”
On key p press - text is “OFF”
next time p press - “ON”
next p press - “OFF”
and so on

I have no idea why this (see image) is not working


p2

Toggling something using toggle variable is what you are looking for

Tak swoją drogą też się z tym męczyłem

1 Like

The reason why it is not working is because both events are processed in sequence.

Here is the current flow of your logic:

Set text ON
Result = ON

If the text is ON, set it to OFF
Result = OFF

If the text is OFF, set it to ON
Result = ON

…So the result will always be ON, no matter what.

Zero’s solution works.

1 Like

Well i guess u dont need my help then

Got it. I treat it as:
if…
else…
statement instead of:
if…
if…

thanks