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.

01local player=game.Players.LocalPlayer
02local pressed=tick()
03local waitTime=.3
04local uis=game:GetService("UserInputService")
05 
06uis.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
15end)
0
this is exactly what i was looking for, thank you very much trubudist 40 — 8y
Ad

Answer this question