would i have to use userinputservice two times, or is debounces needed?
this is not a request
Using UserInputService
and Tick
, I came up with this script. Change waitTime to the amount of time they have to press the button again.
01 | local player = game.Players.LocalPlayer |
02 | local pressed = tick() |
03 | local waitTime = . 3 |
04 | local uis = game:GetService( "UserInputService" ) |
05 |
06 | uis.InputBegan:connect( function (key) |
07 | if key.KeyCode = = Enum.KeyCode.W then |
08 | if tick()-pressed<waitTime then |
09 | print ( "Pressed W twice" ) |
10 | else |
11 | print ( "Pressed W once" ) |
12 | end |
13 | pressed = tick() |
14 | end |
15 | end ) |