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

how do i make it to find out if a player double clicked a keyboard button?

Asked by 8 years ago

would i have to use userinputservice two times, or is debounces needed?

this is not a request

1
Just a simple counter is needed with a set delay for its reset. You could also use a table to store the key pressed ect User#5423 17 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Using UserInputService and Tick, I came up with this script. Change waitTime to the amount of time they have to press the button again.

local player=game.Players.LocalPlayer
local pressed=tick()
local waitTime=.3
local uis=game:GetService("UserInputService")

uis.InputBegan:connect(function(key)
    if key.KeyCode==Enum.KeyCode.W then
        if tick()-pressed<waitTime then
            print("Pressed W twice")
        else
            print("Pressed W once")
        end
        pressed=tick()
    end
end)
0
this is exactly what i was looking for, thank you very much trubudist 40 — 8y
Ad

Answer this question