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: Sprinting

Previous Thread :: Next Thread 
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
03 Jan 2013 04:22 PM
--I want players to sprint when they press the Shift key.
--I'm not sure if 47 is it's interger key.

player = game.Players.LocalPlayer
character = player.Character
humanoid = character.Humanoid
SprintSpeed = 32
DefaultWalkSpeed = 18
Mouse = player:GetMouse()

Mouse.KeyDown:connect(function(key)
if key:byte() == 47 then
humanoid.WalkSpeed = SprintSpeed
end
end)

Mouse.KeyUp:connect(function(key)
if key:byte() == 47 then
humanoid.WalkSpeed = DefaultWalkSpeed
end
end)

--Would this work?

~LUV, LuaLearners Teacher(+3)~
Report Abuse
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
03 Jan 2013 04:23 PM
How about you try it yourself.

wiki.roblox.com
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Jan 2013 04:24 PM
it looks good, but make sure it's a localscript
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
03 Jan 2013 04:24 PM
I already looked at the wiki, I couldn't find it's key.

~LUV, LuaLearners Teacher(+3)~
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
03 Jan 2013 04:25 PM
@cnt, it is.

~LUV, LuaLearners Teacher(+3)~
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
03 Jan 2013 04:25 PM
player = game.Players.LocalPlayer
character = player.Character
humanoid = character.Humanoid
SprintSpeed = 32
DefaultWalkSpeed = 18
Mouse = player:GetMouse()

Mouse.KeyDown:connect(function(key)
if key:byte() == 47 then
humanoid.WalkSpeed = SprintSpeed
repeat until mouse.KeyUp:wait():byte() == 47
humanoid.WalkSpeed = DefaultWalkSpeed
end
end)

there's a more elegant solution. for more info on the wait method: http://wiki.roblox.com/index.php/User:JulienDethurens/Essays/Wait_method

¬ LuaLearners Elite/Writer
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Jan 2013 04:25 PM
The 2 shifts i think are 47 and 48. I think 48 is left shift, the one you want, im not sure.
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
03 Jan 2013 04:30 PM
http://wiki.roblox.com/index.php/Taking_keyboard_input
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
03 Jan 2013 04:30 PM
@doom. I know the wait method. I put them in two seperate functions on purpose.

Wait Method Example:
game.Workspace.Script.Changed:wait()

--It will wait until that event takes place.

~LUV, LuaLearners Teacher(+3)~
Report Abuse
marioblox1094 is not online. marioblox1094
Joined: 14 Aug 2010
Total Posts: 1839
03 Jan 2013 04:32 PM
If you want to know the keys just use the script and in KeyDown put print(key:byte())
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