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 » Scripters
Home Search
 

UserInputService

Previous Thread :: Next Thread 
WhatsItName is not online. WhatsItName
Joined: 29 Jun 2009
Total Posts: 166
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 is not online. 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 is not online. murcury57
Joined: 30 Jun 2010
Total Posts: 90299
23 Jul 2015 02:31 AM
[ Content Deleted ]
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
23 Jul 2015 02:31 AM
use KeyDown?
Report Abuse
gooey333 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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