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 
bluefrog53 is not online. bluefrog53
Joined: 05 Feb 2012
Total Posts: 766
27 May 2015 09:21 AM
Well, I honestly didn't want to do this because KeyDown was working fine but I kept hearing UserInputService is the best way to go. However, I know nothing about it and the wiki wasn't very helpful in explaining what this would actually look like in a script. I know the below is wrong because I don't know how it works. How could I fix this?

input = game:GetService("UserInputService")

input.InputBegan:connect(function(Input)
if Input == "h" then
print"H pressed."
end
end)
Report Abuse
Sinfesizer is not online. Sinfesizer
Joined: 18 Apr 2015
Total Posts: 46
27 May 2015 09:26 AM
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(Input)
if(Input.KeyCode == Enum.KeyCode.H)then
print("H was pressed")
end
end)
Report Abuse
bluefrog53 is not online. bluefrog53
Joined: 05 Feb 2012
Total Posts: 766
27 May 2015 09:28 AM
Thank you. If only we could post that on the wiki.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 May 2015 10:48 AM
The wiki explains it, you just need to read the info.
Report Abuse
Anticodist is not online. Anticodist
Joined: 05 Feb 2014
Total Posts: 1191
27 May 2015 10:49 AM
I recommend using gameProcessedEvent as well to make sure that the code is only called when you're not interacting with UIs.



-𝒩 | Anticodist, Scripter
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
27 May 2015 11:03 AM
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(Input, gameProcessedEvent)
if Input.KeyCode == Enum.KeyCode.H and not gameProcessedEvent then
print("H was pressed")
end
end)
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