Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I check if a player pressed space twice really quickly? (kinda like double jump)

Asked by
zValerian 108
5 years ago

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!

0
use tick() User#19524 175 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You can use tick to check the time between pressing space. Here's an example.

local Input = game:GetService("UserInputService")
local Code = Enum.KeyCode.Space
local Time = 0.5
local Last = nil


Input.InputBegan:Connect(function(Key, Game)
    if not Game and Key.KeyCode == Code then
        if Last then
            if (tick() - Last) <= Time then
                print("Pressed twice in less than "..Time.." seconds.")
            end
        end
        Last = tick()
    end
end) 
Ad
Log in to vote
-1
Answered by 5 years ago

This aint a request website

0
thats why I said anything helps zValerian 108 — 5y
0
technically, we shouldn't help you at all unless you have tried to resolve the problem yourself, or provide some sort of code. turtle2004 167 — 5y
0
True that turtle Voideyz 4 — 5y
0
This isn't an answer to OPs question... User#19524 175 — 5y

Answer this question