|
| 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 |
|
|
|
| 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 |
|
|
|
| 27 May 2015 09:28 AM |
| Thank you. If only we could post that on the wiki. |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:48 AM |
| The wiki explains it, you just need to read the info. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|