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