|
| 12 May 2014 04:57 PM |
I thought about doing a check after .5 seconds to see if it has been pressed twice, but I'm sure there is a shorter way. Perhaps involving 'tick()'
What I have:
local m = game.Players.LocalPlayer:GetMouse(); local pressed = 0; local variable = false;
m.KeyDown:connect(function(key) pressed = pressed +1 variable = true end end)
while wait() do if variable == true then wait(.5) if pressed >= 2 then --do stuff end end end
I'm 99.99% sure there is a shorter way, and I'm not even sure if the way I'm doing it right now will work. |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 05:00 PM |
I checked out the wiki. So is this how I would do it?
tapped = tick()
if tick() - tapped <= .5 and > 0 then --do stuff end |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 05:01 PM |
| Except tapped would be defined when the key is pressed. And then it resets after .5 seconds. |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 05:20 PM |
I fixed some corrections on what I had now.
m.KeyDown:connect(function(k) if (k:lower()) == " w" then if tick() - sprint.SprintTap <= .5 and tick()-sprint.SprintTap > 0 then if anim == false and sprint.sprintVar == false and sprint.extra == false then anim = true sprint.sprintVar = true sprint.extra = true sprint() end end end end) m.KeyUp:connect(function(k) if (k:lower()) == "q" then if anim == true and sprint.sprintVar == true and sprint.extra == true then unsprint() anim = false sprint.sprintVar = false sprint.extra = false end end end)
This is what I currently have, and it isn't working. I think it may have something to do with the tick() stuff. |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 05:22 PM |
| Ok, so now I'm sure the problem is because it isn't detecting if it is being double tapped. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 12 May 2014 05:33 PM |
I recommend reading through this (not mine):
http://www.roblox.com/Re-How-to-detect-if-someone-double-clicks-item?id=138249187
It helped me, at least. |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 May 2014 06:19 PM |
Now I have this. Still won't work:
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(k) if (k:lower()) == 'w' and anim == false and sprint.sprintVar == false then if (tick() - sprint.SprintTap) <= .5 and (tick() - sprint.SprintTap > 0) then anim = true sprint() sprint.sprintVar = true else sprint.SprintTap = tick() end game.Players.LocalPlayer:GetMouse().KeyUp:connect(function(k) if (k:lower()) == 'w' and anim == true and sprint.sprintVar == true then sprint.sprintVar = false unsprint() anim = false end end) end end) |
|
|
| Report Abuse |
|
|
| |
|