Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a doubletap to dash script in my game?

Asked by 6 years ago

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?

0
Use UserInputService to detect player input and see BodyMovers or VectorForces. xPolarium 1388 — 6y
0
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 Elixcore 1337 — 6y
0
but I recommend BodyVelocity, as it worked great for me Elixcore 1337 — 6y
0
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 Ziffixture 6913 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
Note that the interval of time is a little too long in this case, but yeah. Change it to whatever you want ScriptAbyss 10 — 6y
Ad

Answer this question