Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

this is not a request

1 comment

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

1 answer

✓ Accepted answer

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)

1 comment

0

this is exactly what i was looking for, thank you very much

This discussion is preserved as it was. New answers, comments, and votes are closed.