I want that if you double tap "D"or “A”, it will dash but I can’t find how to detect double tap
I have tried a lot of way to obtain this but i cant
I want that if you double tap "D"or “A”, it will dash but I can’t find how to detect double tap
I have tried a lot of way to obtain this but i cant
It seems like this post may answer your question:
As stated by @SeargentAUS , there is already a post answering this question. However, I have written a script tailored to your specific use case:
local UIS = game:GetService("UserInputService")
local leftDashKey = Enum.KeyCode.A
local rightDashKey = Enum.KeyCode.D
local maxDelay = 0.25
local t1 = 0
local t2 = 0
UIS.InputBegan:Connect(function (input, gp)
if gp then return end
if input.KeyCode == leftDashKey then
if tick() - t1 <= maxDelay then
print("dash left")
else
t1 = tick()
end
end
if input.KeyCode == rightDashKey then
if tick() - t2 <= maxDelay then
print("dash right")
else
t2 = tick()
end
end
end)
This code simply creates two congruent systems that compare the elapsed time since the previous key press. If the current key is equal to the previous key and the time since the previous input doesn’t exceed .25 seconds then the script fires and prints to log.
Hope this helps!