FIares
|
  |
| Joined: 07 Nov 2010 |
| Total Posts: 641 |
|
|
| 03 Aug 2015 06:54 PM |
I'm given to understand that KeyDown is now not the right thing to use. I'm currently working in a Server Script, and I was wondering how I can use InputService and if I can use it in a Server Script. A short tutorial would be much appreciated!
They call me Black Sunshine. |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 03 Aug 2015 06:59 PM |
| you don't get user input from a server script. you have to get user input from a local script. |
|
|
| Report Abuse |
|
|
FIares
|
  |
| Joined: 07 Nov 2010 |
| Total Posts: 641 |
|
|
| 03 Aug 2015 07:01 PM |
Can i get a little more detail on how to use it, please?
They call me Black Sunshine. |
|
|
| Report Abuse |
|
|
C0D3Y
|
  |
| Joined: 24 Jul 2010 |
| Total Posts: 1692 |
|
|
| 03 Aug 2015 07:07 PM |
This should answer most/all of your questions. If you have more, feel free to post them on this thread or PM me them specifically.
http://wiki.roblox.com/index.php?title=Gamepad_input |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 03 Aug 2015 07:16 PM |
http://wiki.roblox.com/index.php?title=Keyboard_input
-- local script local UIS = game:GetService("UserInputService") local plr = game.Players.LocalPlayer
UIS.InputBegan:connect(function(input, gameProcessedEvent) if gameProcessedEvent then return end if input.KeyCode == Enum.KeyCode.Y then print(plr.Name.." pressed the Y key!") end end)
you need to acquire userinputservice with get service first. once you have user input service, there are 3 events that will be most important to you in this case: InputBegan, InputChanged, and InputEnded. for just detecting keystrokes, you will only need InputBegan and InputEnded, which in the case you want to detect keystrokes, can be seen as equivalents to KeyDown and KeyUp.
InputBegan, InputChanged, and InputEnded provide 2 parameters for the function you wish to connect to your desired event: inputObject, and gameProcessedEvent. inputObject is an object that contains many properties that can help you determine what kind of input the local player used. you'll want to check the inputObject's KeyCode property for your keystrokes. the .KeyCode property is an enum that determines what key on the user's keyboard was pressed. i'll leave you to discover more about the input object itself here though:
http://wiki.roblox.com/index.php?title=API:Class/InputObject/KeyCode
and then the second parameter, gameProcessedEvent, is a bool being true or false. if gameProcessedEvent is true, then this means that the kind of input the local player used was related to a coregui or textbox, such as if the player is typing in the chatbox. in your situation, you'll want to make sure that gameProcessedEvent is false so that the player wasn't typing a textbox for example. |
|
|
| Report Abuse |
|
|