|
| 23 Jul 2015 02:29 AM |
| Soo I'm told I should no longer use KeyPressed because it is decryptated or whatever. So how do I use UserInputService, I'm on the wiki and it doesn't for me make it clear. Could someone set up the code needed for KeyPressed, like what I should be using for key pressed nowadays. |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 23 Jul 2015 02:31 AM |
game:GetService("UserInputService").InputBegan:connect(function(Key) if Key.KeyCode == Enum.KeyCode.Space then print("Space Pressed!") end end) |
|
|
| Report Abuse |
|
|
murcury57
|
  |
| Joined: 30 Jun 2010 |
| Total Posts: 90299 |
|
| |
|
| |
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 23 Jul 2015 02:31 AM |
| http://wiki.roblox.com/index.php?title=API:Enum/KeyCode |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 23 Jul 2015 02:32 AM |
| Use mine, it will print space when you press it to get you started |
|
|
| Report Abuse |
|
|
Locard
|
  |
| Joined: 13 Apr 2014 |
| Total Posts: 3516 |
|
|
| 23 Jul 2015 02:33 AM |
"decryptated"
I died xD
You would start off by doing game:GetService'UserInputService'.InputBegan:connect(function(input,gpe) if not gpe then --learn about the input object in the wiki! end end) |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 23 Jul 2015 02:40 AM |
"decryptated" This just makes me feel great.
Essentially, you need to use the InputBegan event in the place of the KeyDown event. InputBegan returns 2 values; The input object, and whether or not the event was fired as a gameprocessed event. The second value just means something like chatting, which is useful because often times, you don't want this event to be firing while you're typing in the chat(:
So, make sure it's not a game processed event, then check the input, then do your code(:
local uis = game:GetService('UserInputService'); --Define UserInputService
uis.InputBegan:connect(function(input,process) --Define the event if not process then --Make sure it's not a GPE if input.KeyCode == Enum.KeyCode.E then --If they pressed 'E' --Your code end end end) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 23 Jul 2015 02:42 AM |
local uis = game:GetService("UserInputService")
uis.InputBegan:connect(function(input, event) if not event then if input.KeyCode == Enum.KeyCode.E then print("Pressing E") end end end)
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|