One example: Double jumping. What I'm trying to make is when you press "SPACE" twice, you get thrusted fowards.
p = script.Parent.Parent repeat wait() until p.Character c = p.Character print("HELLO") mouse = p:GetMouse() ticknow = nil tickaft = nil mouse.KeyDown:connect( function(key) key = key:lower() if key:byte() == 32 and not ticknow then ticknow = time() print("HALLO") elseif key:byte() == 32 and ticknow then print("HERRO") tickaft = time() if tickaft - ticknow < 1 then print("DOUBLE DUH STOOF") tickaft = nil ticknow =nil end end end)
Regardless of what I do, it either prints out the double function or gets stuck on "HERRO"
This is pretty straight forward, the basic idea is to check the time between two presses and see if it is lower than a certain value
mouse = game.Players.LocalPlayer:GetMouse() local last = tick() mouse.KeyDown:connect(function(key) local cur = tick() if key == " " then if cur-last < 0.3 then print("Doble taps") end end last = cur end)
Whenever I need something to happen after something happens, I just set it up with an anonymous function firing after the first time it happens, then either an until loop that stops when it happens again or another anonymous function that fires when it happens again.