Download

How to deny a key press after a certain event has happened?

I have a flash light working with a decay rate. You press F once to turn it on and a sound plays, press again to turn off and sound plays. After the power value reaches 0 it shorts out and a sound plays BUT you can still press F and the sound still plays. How would i make it so sound no longer plays when power is at 0? I have been messing around myself but have not come up with the result i need.

Add a Boolean that is set the first time the button is pressed (e.g. isFlashlightOn) … have this set to false when it shorts out. Now on Key Press … check the Boolean … if it is off then perform normal step … if it is set, ignore it.

Sorry for grave digging this post but how would I ignore it?

I have this but im not sure what to put at true to make it ignore the key press
3f96a7b0fe921457871246e051fd3e91b21f5b80.png

FL.jpg

This way you can’t turn the flashlight on if it’s battery is depleted.