Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

1 comment

0

It works! thanks so much! :)

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).

3 comments

0

attempt to index local 'numb' (a number value)* The script does not work :/

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.