|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 03 Jan 2013 04:25 PM |
@cnt, it is.
~LUV, LuaLearners Teacher(+3)~ |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 03 Jan 2013 04:30 PM |
| http://wiki.roblox.com/index.php/Taking_keyboard_input |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|