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: Need help with binding the Shift key for Sprint feat.

Previous Thread :: Next Thread 
ajfg is not online. ajfg
Joined: 10 Mar 2013
Total Posts: 37
19 Mar 2013 06:45 PM
Before I say anything, I'm going to start off by saying that I am a COMPLETE newbie to scripting and this is also an alt that I'm too lazy to log out of.

Now...
I'm making a game:

http://www.roblox.com/Somewhat-Modern-Blockfare-3-Dome-place?id=82979397

It's basically Dome from MW3.

I took Ubayla's Gun System (which is very glitchy...):

http://www.roblox.com/Gun-System-item?id=68031752

There's this one part in the script controlling the sprinting feature (I edited a value but that's all):

elseif key == "w" then
if aiming == false and Reloading == false and throwing == false and swinging == false and Sprint > 0 then
t = r.Stepped:wait()
if (t - Double < 0) then
sprinting = true
welds[1].C0 = CFrame.new(-1, -1.5, -0.8) * CFrame.Angles(math.rad(50), 0, math.rad(-25))
welds[2].C0 = CFrame.new(0.4, -1.2, -0.4) * CFrame.Angles(math.rad(90), math.rad(25), math.rad(-50))
welds[3].C0 = CFrame.new(-1, -1.5, -0.8) * CFrame.Angles(math.rad(50), 0, math.rad(-25))
welds[4].C0 = CFrame.new(0.4, -1.2, -0.4) * CFrame.Angles(math.rad(90), math.rad(25), math.rad(-50))
crouching = false
prone = false
welds[6].Part1 = nil
welds[7].Part1 = nil
hi[1].Part1 = legs[1]
hi[2].Part1 = legs[2]
legs[1].Name = "Left Leg"
legs[2].Name = "Right Leg"
legs[1].CanCollide = false
legs[2].CanCollide = false
MinRecoil = MinRecoil + 0.1
Tool.Parent.Humanoid.WalkSpeed = 20
wait()
Camera.FieldOfView = 72
wait()
Camera.FieldOfView = 74
wait()
Camera.FieldOfView = 76
wait()
Camera.FieldOfView = 78
wait()
Camera.FieldOfView = 80
end
Double = t
end

I want to change "w" to the shift key. I looked into CloneTrooper1019's Sprint Script and it says this:

mouse.KeyDown:connect(function (key) -- Run function
key = string.lower(key)
if string.byte(key) == 48 then
running = true
local keyConnection = mouse.KeyUp:connect(function (key)
if string.byte(key) == 48 then
running = false
end
end)
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (70+(i*2))
wait()
end
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 24
repeat wait () until running == false
keyConnection:disconnect()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (80-(i*2))
wait()
end
end
end)

My question is: How can I get my game's gun to detect the Shift button? Should I try this?:

elseif string.byte(key) == 48 then

I don't want to save anything until I'm sure this will work.

Sorry for the long post! :(
Report Abuse
ajfg is not online. ajfg
Joined: 10 Mar 2013
Total Posts: 37
19 Mar 2013 06:49 PM
Bump?

:<
Report Abuse
ajfg is not online. ajfg
Joined: 10 Mar 2013
Total Posts: 37
19 Mar 2013 06:53 PM
Hello? ):
Report Abuse
ajfg is not online. ajfg
Joined: 10 Mar 2013
Total Posts: 37
19 Mar 2013 06:59 PM
I think I'm being ignored because I'm not including everything in the script that involves sprinting.

Eh. :/
Report Abuse
hotshadow10 is not online. hotshadow10
Joined: 27 Jan 2012
Total Posts: 83
11 Jun 2014 06:35 PM
you need to change your attitude mister. You understand me?
Report Abuse
Frantuary is not online. Frantuary
Joined: 11 Jul 2012
Total Posts: 11315
11 Jun 2014 06:47 PM
read the rules

No arms, and you can still use a calculator!
Report Abuse
Redbullusa is not online. Redbullusa
Joined: 18 Feb 2009
Total Posts: 43
17 Jul 2014 02:05 PM
I decided to ignore the scripts & tell you that the key for Shift should be "0."
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
17 Jul 2014 02:06 PM
Left Shift's byte code is 48
Report Abuse
Redbullusa is not online. Redbullusa
Joined: 18 Feb 2009
Total Posts: 43
17 Jul 2014 02:06 PM
The code for the Shift key is "48," though.

http://wiki.roblox.com/index.php?title=Taking_keyboard_input#Special_keys
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
17 Jul 2014 02:06 PM
You HAVE to use UserInputService and check if InputObject.KeyCode == Enum.KeyCode.LeftShift or Enum.KeyCode.RightShift.
Report Abuse
Redbullusa is not online. Redbullusa
Joined: 18 Feb 2009
Total Posts: 43
17 Jul 2014 02:07 PM
What SenseiWarrior said.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
17 Jul 2014 02:10 PM
Except so is 0. Using UserInputService is the only way to get Left/Right Ctrl/Alt/Shift, Caps, Tab, Escape, the F## keys, etc without conflicts.
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