I want to make a double tap W to dash script in my game but i dont know how to could someone give me an idea of what i would need to do to make it work and i can figure out the rest from there?
COMMUNITY QUESTION
How do i make a doubletap to dash script in my game?
1 answer
I would do something like that. I don't know if 'DoubleDebounce' is the appropriated term in this kind of context, but yeah. I didn't also do, but you may add a Debounce that way the player can't spam this move.
local DoubleDebounce = false
local UserInputService = game:GetService('UserInputService')
local TargetKeyCode = Enum.KeyCode.W
UserInputService.InputBegan:Connect(function(input,gameEvent)
if not gameEvent and input.KeyCode == TargetKeyCode then
if not DoubleDebounce then
DoubleDebounce = true
spawn(function()
wait(1) --Interval of time where the player can double tap a key
DoubleDebounce = false
end)
elseif DoubleDebounce then
print('Dashing') --Perform a dashing action
DoubleDebounce = false
end
end
end)
1 comment
0
Note that the interval of time is a little too long in this case, but yeah. Change it to whatever you want
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Use UserInputService to detect player input and see BodyMovers or VectorForces.
I have a script for that but if I gave you it, it would be feeding so I'd rather not. Just do what the person above said
but I recommend BodyVelocity, as it worked great for me
I suggest ContextActionService, creates a custom button like the Jump-pad with any given function, same function can also apply to PC’s as well if it’s read as not a mobile device, simply uses a KeyCode Enum instead to run it