I've tried multiple scenarios. What I am trying to do is allow a basic function to fire when You double tap "A", but I can't seem to do it. I assume the problem is that input2 is already being set as "A" when I first press it because pressing it for the second time in the game means that every time you press it hence it will fire the function.
01 | bool = true |
02 | locplay = game.Players.LocalPlayer |
03 | human = locplay.Character.Humanoid |
04 | game:GetService( "UserInputService" ).InputBegan:connect( function (input 1 ) |
05 | if input 1. KeyCode = = Enum.KeyCode.A then |
06 | local bool = false |
07 | wait(. 02 ) |
08 | if bool = = false then |
09 | game:GetService( "UserInputService" ).InputBegan:connect( function (input 2 ) |
10 | if input 2. KeyCode = = Enum.KeyCode.A then |
11 | local bool = true |
12 | if bool = = true then |
13 | human.WalkSpeed = 50 |
14 | wait(. 25 ) |
15 | human.WalkSpeed = 16 |
Try this code out:
01 | click = false |
02 | locplay = game.Players.LocalPlayer |
03 | human = locplay.Character.Humanoid |
04 | game:GetService( "UserInputService" ).InputBegan:connect( function (input 1 ) |
05 | if input 1. KeyCode = = Enum.KeyCode.A then |
06 | if click then |
07 | print ( "A was double tapped" ) |
08 | return |
09 | end |
10 | click = true |
11 | wait( 0.4 ) |
12 | click = false |
13 | end |
14 | end ) |