So I have this heal part thing, but I would like a debounce on it. Any suggestions, or ideas??
1 | script.Parent.Touched:connect( function (p) |
2 | if p.Parent:FindFirstChild( "Humanoid" ) then |
3 | p.Parent.Humanoid.Health = 100 |
4 | end |
5 | end ) |
If I knew a basic debounce script, I could add this to GUI's and stuff like that, but I don't know how to. Any help?
I think I understand what you mean. I think it would be something like this,
01 | local buttonPressed = false |
02 | --Store whether the button is pressed in a local variable |
03 |
04 | Workspace.Button.Touched:connect( function (hit) |
05 | if not buttonPressed then |
06 | -- Is it not pressed? |
07 |
08 | buttonPressed = true |
09 | -- Mark it as pressed, so that other handlers don't execute |
10 |
11 | print ( "Button pressed" ) |
12 | wait( 1 ) |
13 | print ( "Hi :D" ) |
14 | -- Do Stuff |
15 |
16 | buttonPressed = false |
17 | -- Mark it as not pressed, so other handlers can execute again |
18 | end |
19 | end ) |
Hope this helps you!