How can I check double input?

Hey I want check if I input 2 times the same input but I have some isuess can somoene help please?

local DashKeys = {
[Enum.KeyCode.W] = 'Forward',
[Enum.KeyCode.A] = 'Left',
[Enum.KeyCode.S] = 'Backward',
[Enum.KeyCode.D] = 'Right'
}

local lastDash = tick()
local min = .5

UserInputService.InputBegan:Connect(function(key, locked)
if locked then return end
	
if (key.KeyCode == Enum.KeyCode[DashKeys] and tick() - LAST_DASH >= COOLDOWN) then
	local now = tick()
		if now - lastDash <= min then
			print("hey")
ebd
end)

Use another table that contains booleans which represents whether they are pressed down or not. The InputBegan will toggle them true and vice versa with InputEnded.

can you show me how I could solve it?

Oops! I mistook the double input for two different keys. Apparently you’re looking for double-tap. Here are similiar topics though:

1 Like

but I need it like I showed you in my script

Forward and Left and Backward was made because I needed to make this:

UserInputService.InputBegan:Connect(function(key, locked)
	if locked then return end
	
	if (key.KeyCode == Enum.KeyCode[DashKeys] and tick() - LAST_DASH >= COOLDOWN) then
		local now = tick()
		
		local mixedDirection = Vector3.new(0, 0, 0)
		local animationCode = 0

		for dashKey, directionName in pairs(DashKeys) do
			if UserInputService:IsKeyDown(dashKey) then
				LAST_DASH = tick()
				

				if now - lastDash <= min then
				animationCode += GetAnimationCodeByName(directionName)
				
					local direction = GetDirection[directionName]()
					mixedDirection += direction
				end
			end
		end

end)

so how can I fix this problem with using the Table I have been created?

Please try to solve my Problem with influence my script

The code could be condensed this way. Only issue I know about this one is the rigidity.

local lastDash = tick()
local lastTap
local min = .5

UserInputService.InputBegan:Connect(function(key, locked)
	if locked then return end
	
	if (key.KeyCode == Enum.KeyCode[DashKeys] and tick() - lastDash >= min) then
		if lastTap == key.KeyCode then
			-- dash!!!
			lastDash = tick()
			lastTap = nil
		else
			lastTap = key.KeyCode
		end
	end
end)

image

something is wrong with my table but my table is important I cant change it

if (dashKeys[key.KeyCode] ~= nil and (tick() - LAST_DASH) >= COOLDOWN) then
1 Like