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: KeyDown Check Times

Previous Thread :: Next Thread 
itachi5036 is not online. itachi5036
Joined: 19 Apr 2009
Total Posts: 481
04 Sep 2013 02:24 PM
How can I make the code that I made in a localscript below work to where only when spacebar gets pressed twice in a row (swiftly) that the code: "player.Character.Humanoid.Health = 0" will execute?

(Code below)

player = game.Players.LocalPlayer
count = 0
mouse.KeyDown:connect(function( key )
key:lower()
if key == " " then
count = count + 1
if count == 2 then
player.Character.Humanoid.Health = 0
count = 0
end
end
end)
Report Abuse
chaokid9 is not online. chaokid9
Joined: 29 Aug 2008
Total Posts: 6187
04 Sep 2013 02:26 PM
I would make a script that detects when the value of count changes and then wait a certain amount of time then reset the value to zero.
Report Abuse
itachi5036 is not online. itachi5036
Joined: 19 Apr 2009
Total Posts: 481
04 Sep 2013 02:27 PM
Can you give an example?
Report Abuse
chaokid9 is not online. chaokid9
Joined: 29 Aug 2008
Total Posts: 6187
04 Sep 2013 02:33 PM
Ok, so you will need to make "Count" an actual value like an integer value and not just a value in the script.

So you would have your first script:

player = game.Players.LocalPlayer
count = LOCATION OF COUNT VALUE
count.Value = 1
mouse.KeyDown:connect(function( key )
key:lower()
if key == " " then
count.Value = count.Value + 1
end
end)

Script 2:

player = game.Players.LocalPlayer
count = LOCATION OF COUNT VALUE
mouse.KeyDown:connect(function( key )
key:lower()
if key == " " then
wait(0.5)
if count.Value >= 2 then
player.Character.Humanoid.Health = 0
count.Value = 0
end
end
end)

Report Abuse
Soquick is not online. Soquick
Joined: 01 Nov 2012
Total Posts: 1497
04 Sep 2013 02:42 PM
go to my ForumStuffForPeeps in starterpack, script is dere
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