nova981
|
  |
| Joined: 15 Sep 2012 |
| Total Posts: 6274 |
|
|
| 25 Oct 2014 04:36 PM |
| I want to make a sprint script using shift. Don't give me a whole script, just tell me how to do something while a key is held down. |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 04:37 PM |
| use InputBegan, the Key events are deprecated |
|
|
| Report Abuse |
|
|
Reqkt
|
  |
| Joined: 17 Jun 2014 |
| Total Posts: 210 |
|
|
| 25 Oct 2014 04:40 PM |
keydown = false
LocalPlayer:GetMouse() KeyDown (function(key) if key = Shift keydown = true
while keydown -- stuff end end end)
LocalPlayer:GetMouse() KeyUp (function(key) if key = Shift keydown = false end end) |
|
|
| Report Abuse |
|
|
Reqkt
|
  |
| Joined: 17 Jun 2014 |
| Total Posts: 210 |
|
|
| 25 Oct 2014 04:41 PM |
http://wiki.roblox.com/index.php?title=API:Class/Mouse/KeyDown
These need to be labelled as deprecated, then. |
|
|
| Report Abuse |
|
|
CarlosMX
|
  |
| Joined: 30 Apr 2011 |
| Total Posts: 791 |
|
|
| 25 Oct 2014 04:49 PM |
^ your script woulda broke, heres fixed version:
keydown = false
LocalPlayer:GetMouse() KeyDown (function(key) if key == "q" then keydown = true
while keydown == true do -- stuff end end end)
LocalPlayer:GetMouse() KeyUp (function(key) if key == Shift then keydown = false end end)
|
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 04:50 PM |
The mouse events aren't deprecated at all... It's just that UserInputService is more precise when it comes to key input, and offers more flexibility.
~The herp lerped a derp~ |
|
|
| Report Abuse |
|
|
Reqkt
|
  |
| Joined: 17 Jun 2014 |
| Total Posts: 210 |
|
|
| 26 Oct 2014 10:29 AM |
@Carlos There are plenty of things you missed to make it run. It was pseudocode, not an actual script. A proof-of-concept, if you will. |
|
|
| Report Abuse |
|
|
murcury57
|
  |
| Joined: 30 Jun 2010 |
| Total Posts: 90299 |
|
| |
|