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: How to call on Ctrl in a script. What's the word for it?

Previous Thread :: Next Thread 
Lentzified is not online. Lentzified
Joined: 06 Dec 2009
Total Posts: 138
31 Aug 2014 10:12 PM
Hey guys! I'm making a paintball map and I want to make Ctrl or Shift a sprint key. Here's the beginning of the LocalScript inside the tool:
local tool = script.Parent
tool.Equipped:connect(function(mouse)
mouse.KeyDown:connect(function(key)
if key == "Ctrl" then
print"The key works now!"
end
end)
end)

I know the rest of the script is fine because I tried it with "h" and "g" and "z", but how would I make it control? Any help is needed. Thanks so much!
Report Abuse
Subete is not online. Subete
Joined: 10 Jul 2011
Total Posts: 917
31 Aug 2014 10:16 PM
relatively sure you need some number for ctrl

there is a function in the roblox wiki that tells you the info about a key you press, just put tht print function in something nd start pressing keys to figure out what you need for them
Report Abuse
Lentzified is not online. Lentzified
Joined: 06 Dec 2009
Total Posts: 138
31 Aug 2014 10:17 PM
Will do. Thanks.
Report Abuse
Lentzified is not online. Lentzified
Joined: 06 Dec 2009
Total Posts: 138
31 Aug 2014 10:26 PM
Found the page! You were right! Here's the new script!

local tool = script.Parent
tool.Equipped:connect(function(mouse)
mouse.KeyDown:connect(function(key)
if key == string.char(50) then
print"am work k"
end
end)
end)

You were a big help! If you need the script its the roblox wiki and search "Taking Keyboard Input"!
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
31 Aug 2014 10:32 PM
in a local script
wait(1)
Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.KeyDown:connect(function(key)
if key == string.char(50) then
print"am work k"
end
end)

You don't need to use a tool to get the mouse and you don't necessarily need to use a number (string.char) to reference to the key but you probably should, since it can get a little weird for keys aren't letters.
Report Abuse
Lentzified is not online. Lentzified
Joined: 06 Dec 2009
Total Posts: 138
31 Aug 2014 11:39 PM
Yeah I know but this actually works now! Like I'm making the rest of the script and it works, plus I have the page I used in bookmarks so as long as it works for me!
Report Abuse
Subete is not online. Subete
Joined: 10 Jul 2011
Total Posts: 917
31 Aug 2014 11:41 PM
Glad I could be of assistance to you. :p

Although you did the hard part of it on your own I guess
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