generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do I check if a player pressed a key twice?

Previous Thread :: Next Thread 
Cr0ws is not online. Cr0ws
Joined: 16 Aug 2013
Total Posts: 1545
20 Aug 2014 03:19 PM
plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
Eq = false
mouse.KeyDown:connect(function(key)
if key == "f" then
Eq = true
end

--Player presses f again..
Eq = false

end)
Report Abuse
Tynexx is not online. Tynexx
Joined: 11 Jul 2012
Total Posts: 1559
20 Aug 2014 03:43 PM
local eq = false
mouse.KeyDown:connect(function(Key)
key=Key:lower()
if key=="f" then
if eq==false then
eq=true
else
--dostuff
eq=false
end
end
end)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
20 Aug 2014 03:56 PM
plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
keys = {}
speed = 0.1
mouse.KeyDown:connect(function(key)
if not keys[key:byte()] then
keys[key:byte()] = true
delay(speed,function() keys[key:byte()] = nil end)
if mouse.KeyDown:wait():byte() == key:byte() and keys[key:byte()] then
print(key,'with a byte of',key:byte(),'has been pressed.)
end
end
end)
Report Abuse
PropheticExtinction is not online. PropheticExtinction
Joined: 16 Nov 2008
Total Posts: 5686
20 Aug 2014 04:37 PM
give em a kl

lolol

jk u can just stalk dem


If we couldn't laugh, we would all go insane. | PropheticExtinction
Report Abuse
Cr0ws is not online. Cr0ws
Joined: 16 Aug 2013
Total Posts: 1545
21 Aug 2014 07:20 PM
kl?
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
21 Aug 2014 07:22 PM
hes just joking
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
21 Aug 2014 07:29 PM
local lastPressed = {}
local doubleTapTime = .1
game:GetService'UserInputService'.InputBegan:connect(function(inputObj)
if inputObj.UserInputType == Enum.UserInputType.Keyboard then
lastPressed[inputObj.KeyCode] = lastPressed[inputObj.KeyCode] or 0
local timePressed = tick()
if timePressed - lastPressed[inputObj.KeyCode] <= doubleTapTime then
--Execute Code
end
lastPressed[inputObj.KeyCode] = timePressed
end
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image