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: While key is held down?

Previous Thread :: Next Thread 
nova981 is not online. 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
pr0tractor is not online. pr0tractor
Joined: 07 Sep 2014
Total Posts: 41
25 Oct 2014 04:37 PM
use InputBegan, the Key events are deprecated
Report Abuse
Reqkt is not online. 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 is not online. 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 is not online. 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
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
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 is not online. 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 is not online. murcury57
Joined: 30 Jun 2010
Total Posts: 90299
26 Oct 2014 10:35 AM
[ Content Deleted ]
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