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
 

[ Content Deleted ]

Previous Thread :: Next Thread 
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
06 Apr 2014 09:23 PM
An example of it please?
Report Abuse
TecmagDiams is not online. TecmagDiams
Joined: 18 Sep 2008
Total Posts: 1882
06 Apr 2014 09:25 PM
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key) print(key) end)
Report Abuse
beastyfootballtim is not online. beastyfootballtim
Joined: 30 Oct 2010
Total Posts: 1080
06 Apr 2014 09:27 PM
Which key is that line referring too?
Report Abuse
NeonRiver is not online. NeonRiver
Joined: 12 Feb 2013
Total Posts: 4936
06 Apr 2014 09:29 PM
[ Content Deleted ]
Report Abuse
TecmagDiams is not online. TecmagDiams
Joined: 18 Sep 2008
Total Posts: 1882
06 Apr 2014 09:31 PM
All of them. KeyDown is called anytime any key is pressed, and it passes in the key that was pressed.

So that line will print every key hit from then on. If you want something to happen only when a certain key is pressed you can check against it as follows:

game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
if key == 'r' then
print("The 'r' key was hit!")
end
end)

Also note that this only works in localscripts, because server scripts don't have access to the mouse (which also is the keyboard).
Report Abuse
NeonRiver is not online. NeonRiver
Joined: 12 Feb 2013
Total Posts: 4936
06 Apr 2014 09:33 PM
[ Content Deleted ]
Report Abuse
xDeathBear is not online. xDeathBear
Joined: 09 Jul 2010
Total Posts: 1657
06 Apr 2014 09:34 PM
What would the enter key be called?
The right enter.
Report Abuse
TecmagDiams is not online. TecmagDiams
Joined: 18 Sep 2008
Total Posts: 1882
06 Apr 2014 09:35 PM
Wrong. It should be the convention of the person who answered the question. I much rather have all my code follow the same format and call print as a function such as print(args) rather than print args.

Please don't try to correct what is already correct.
Report Abuse
TecmagDiams is not online. TecmagDiams
Joined: 18 Sep 2008
Total Posts: 1882
06 Apr 2014 09:41 PM
If you want to start working with non-character keys you will need to use the character literal function ":byte()"

For a reference list please check the wiki: http://wiki.roblox.com/index.php/Taking_keyboard_input

So we can just adapt the old code I posted as follows:
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
if key:byte() == 13 then
print("The '↵ Enter' key was hit!")
end
end)

There are a few other ways as well, such as by comparing the key to a representation of a character from an int, or by using the escape sequences that represent these characters.
Report Abuse
NeonRiver is not online. NeonRiver
Joined: 12 Feb 2013
Total Posts: 4936
06 Apr 2014 09:47 PM
[ Content Deleted ]
Report Abuse
TecmagDiams is not online. TecmagDiams
Joined: 18 Sep 2008
Total Posts: 1882
06 Apr 2014 09:50 PM
NeonRiver,
Both work.

print "Test"
print("Test")

both of these output the same exact thing. Both work. Neither are wrong in technical standards. The only time they are wrong is when you switch between using them. It's called convention. Things that don't HAVE to be one way, but ARE. I call print(args) because all other functions I use (be that I wrote them or they are base functions included) are called as function(args).
Report Abuse
baheeg is not online. baheeg
Joined: 19 Jul 2010
Total Posts: 72846
06 Apr 2014 10:21 PM
Neon

no it should be what he said because
the function requires an end + parenthesis and the if statement requires an end
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
06 Apr 2014 10:47 PM
local mouse = game.Players.Goulstem:GetMouse()

mouse.KeyDown:connect(function(key)
print("Pressed Key: "..key)
end)

>Pressed Key: (Key that I pressed)
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