How to detect if a keyboard key is pressed more than once

I just want to know!!! :smiley:

2 Likes

its quite a simple concept, the way games/apps knows how many times you clicked is by counting how many times you clicked the button for a certain interval, you could use tick() to know the last time a player has clicked and then compare it to the current tick(), if its longer than the set interval then we reset the variable of “amountClicked” to 0, here’s a code example:

local uis = game:GetService("UserInputService")

local interval = 1
local amountClicked = 0
local lastTick = tick()

uis.InputBegan:Connect(function(input, gps)
	if input.KeyCode == Enum.KeyCode.V then
		if tick()-lastTick >= interval then
			amountClicked = 0
		end
		lastTick = tick()
		amountClicked += 1
		print('clicked '..amountClicked..' times')
	end
end)

if you have any questions, please let me know!

4 Likes

Thanks so much!!! :grin:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.