My first suggestion would be to use the UserInputService since KeyDown and KeyUp are deprecated methods of getting user input.
With that in mind there are two events we need in the UserInputService:
http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputBegan
http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputEnded
The first event, InputBegan, fires when the user presses a key down or their mouse up.
The second event, InputEnded, fires when the user stops pressing a key down or up.
These events also give us something called input objects:
http://wiki.roblox.com/index.php?title=API:Class/InputObject
One of their properties is the KeyCode property:
http://wiki.roblox.com/index.php?title=API:Class/InputObject/KeyCode
It returns an enum of the key pressed (assuming it exists otherwise nil). The enum list can be found here: http://wiki.roblox.com/index.php?title=API:Enum/KeyCode remeber though, intellisense is a life saver sometimes.
That being said, we have a enough information now to solve your problem.
01 | local player = game:GetService( "Players" ).LocalPlayer; |
02 | local character; repeat wait(); character = player.Character; until character; |
03 | local humanoid = character:WaitForChild( "Humanoid" ); |
05 | local inputService = game:GetService( "UserInputService" ); |
07 | inputService.InputBegan:connect( function (input, process) |
08 | if process then return ; end ; |
09 | if input.KeyCode = = Enum.KeyCode.LeftShift then |
10 | humanoid.WalkSpeed = 30 ; |
14 | inputService.InputEnded:connect( function (input, process) |
16 | if input.KeyCode = = Enum.KeyCode.LeftShift then |
17 | humanoid.WalkSpeed = 16 ; |