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

I need help with my double tapping script may you give me an idea on how to do it?

Asked by
Hero_ic 502 Moderation Voter
9 years ago

I've been trying to make a double tap script but nothing is working :/

        if input.KeyCode == Enum.KeyCode.D or input.KeyCode == Enum.KeyCode.Right and doubleTime == false then
            doubleTime = true 
            wait(.5)
            if doubleTime == true then
                humanoid.WalkSpeed = 24
                print("run")
            else
                humanoid.WalkSpeed = 16             
            end
        end

this is one of the attempts I did also in a renderstepped event the doubleTime = false after a wait but this still does not work correctly I want it to be like if I press d-d in under 1.1 seconds I start sprinting.

thanks for taking the time reading or helping me. ~KIHeros

(this question was rushed...)

2 answers

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

The common way to make a double click or double tap is with use of tick(). This lets you compare the time when they last clicked to the current time. If there's only a slight difference between the times of last click and current click, treat it as a double click.

local lastTapTime = tick()

function onTap()
    if tick() - lastTapTime < 1 then
        print("double Click!")
    end
    lastTapTime = tick()
end
0
It works! thanks so much! :) Hero_ic 502 — 9y
Ad
Log in to vote
-2
Answered by 9 years ago
local key = "f"
local num = 0 -- don't change
local reqnum = 2 -- how many taps
local waitTime = 1.1

function add()
    num = num + 1
end

num.Changed:connect(function()
    if num == reqnum then
        sprint() -- func for your sprinting
        return
    elseif num == 0 then
        return
    end
    wait(waitTime)
    if num < reqnum then
        num = 0
    end
end)

local context = game:GetService("ContextActionService")
context:BindAction("Tap",add,false,key)

This should do it.

Adds one every time you tap, when it reaches reqnum, it does the function (in this case, sprint).

0
attempt to index local 'numb' (a number value)* The script does not work :/ Hero_ic 502 — 9y
0
ugh, why do people be so cruel...? i tried to help, and it was wrong. i spent ages on this. And this 'numb' has nothing to do with my script. do my stuff correctly, i'm not losing reputation because someone can't integrate a script into their own TheDeadlyPanther 2460 — 9y
0
sorry if that's offensive, but it gets me pissed off when people blame me for their failure. Instead, you could have asked me how to fix it. TheDeadlyPanther 2460 — 9y

Answer this question