I am making a script that fires an event when the player press space twice quickly, as if they were double jumping. I have no idea how to do this or how to check if the player pressed space twice quickly. Is it possible and if it is, how? Anything helps!
You can use tick to check the time between pressing space. Here's an example.
01 | local Input = game:GetService( "UserInputService" ) |
02 | local Code = Enum.KeyCode.Space |
03 | local Time = 0.5 |
04 | local Last = nil |
05 |
06 |
07 | Input.InputBegan:Connect( function (Key, Game) |
08 | if not Game and Key.KeyCode = = Code then |
09 | if Last then |
10 | if (tick() - Last) < = Time then |
11 | print ( "Pressed twice in less than " ..Time.. " seconds." ) |
12 | end |
13 | end |
14 | Last = tick() |
15 | end |
16 | end ) |
This aint a request website