I have a singular function, but whenever that function activates, the same function can be activated again. How do I prevent the function from happening, whilst the same function is functioning
example: I stand next to a sensor with the door, but since I'm standing with the sensor, the door slams me in the face and opens until I'm not in the sensor.
A debounce is a boolean flag that you use to keep track of when the function is active and when it is not, implemented as such:
debounce = false function YourFunction() if not debounce then debounce = true --Do your stuff debounce = false end end
Add a debounce to the function, so the function will only run after it has been completely executed, or in your case, it will only run after you step off the sensor.