|
| 17 May 2015 11:19 PM |
| Can someone write out the scritpt thing for it and how choose the key, just don't know. |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 May 2015 11:20 PM |
| I tryed that it isn't there, just for the decriyptated KeyPressed |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 17 May 2015 11:22 PM |
local UIS = game:GetService("UserInputService") local forwardKey = "W"
UIS.InputBegan:connect(function(input, gameProcessedEvent) if debounce == false then print(input.KeyCode.Name) if input.KeyCode == Enum.KeyCode[forwardKey] then char.moveForward.Value = true end end end) |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 May 2015 11:22 PM |
| http://wiki.roblox.com/index.php?title=Keyboard_input#UserInputService |
|
|
| Report Abuse |
|
|
| |
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 17 May 2015 11:25 PM |
If you plan on doing only keydown functions rather than messing with mobile device interactions and so on, I would suggest using the :GetMouse() method on a player and using a keydown for that.
It is much simpler, doesn't require getting a service, and it doesn't require a whole lot of 'if's just do decipher what the hell the player pressed.
Prepare yourself though, amanda will always disagree and say that user input service is better even though it requires a whole lot more setup for the same purpose (that is if you are only doing keydown for el~ keyboard) |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 11:28 PM |
| KeyDown is an outdated version of UserInputService. Yes, use the outdated, way too abstract implementation that requires the player exists for it to work, and could be completely removed at any time. Good idea. |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 17 May 2015 11:32 PM |
@nQ, Ok ya' buggar 'abstract' g()0d 1 m8.
I'm just saying that User Input Service seems stupid and a whole lot more work if you aren't planning on doing anything beyond keys.
That would be like you telling someone to use Remote Events when they aren't using filtering enabled.
More setup/time/work isn't worth it if you have an easy solution.
Please re-think your lyfe m8 <3 |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 11:39 PM |
| UserInputService really isn't even more difficult, unless it makes it more difficult just because it uses Enums? |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 11:40 PM |
| Also, there are reasons to use RemoteEvents/functions with FE disabled. |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 17 May 2015 11:42 PM |
There are plenty m0re ifs when you use UIS
whereas keydown is as simple as
M.KeyDown:connect(function(K) if K:lower() == 'Blank' then end end)
With UIS it is all about
game:GetService('UserInputService') if not gameProcessedEvent then if key.enum bla bla bla etc. then
User input service is m0re w0rk end of st0ry |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 11:44 PM |
KeyDown:
while game.Players.LocalPlayer == nil do game.Players.Changed:wait() end
local player = game.Players.LocalPlayer local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key) if key == "A" then --code end end)
UserInputService:
local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function(inputObject, gameProcessedEvent) if not gameProcessedEvent and inputObject.KeyCode == Enum.KeyCode.A then --code end end)
Yep so much more difficult. |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 11:46 PM |
With ContextActionService, you don't even need to check GameProcessedEvent
local CAS = game:GetService("ContextActionService")
function onInput(actionName, inputState) if inputState == Enum.UserInputState.Begin then --code here end end
CAS:BindAction("onInput", onInput, false, Enum.KeyCode.A) |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 17 May 2015 11:48 PM |
Pls kri more ya' cheeky k00n
No wundr u hab no frends
No wunder bred u hab no t0ast
Back on tawpik, you did some necessary st00f
local M = game.Players.LocalPlayer:GetMouse()
That is a whole lotta' less lines.
You must be bad at scripting <3 |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 11:50 PM |
local M = game.Players.LocalPlayer:GetMouse()
Oh no, the player hasn't loaded yet and this throws an error because of how unreliable this method of keyboard input is. Too bad, better luck next time. |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 11:50 PM |
| Still shorter to use ContextActionService anyways. |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 17 May 2015 11:51 PM |
'Oh no, the player hasn't loaded yet and this throws an error because of how unreliable this method of keyboard input is. Too bad, better luck next time.'
>Local script is a descendant of the player, if the local script is running, the player exists.
Please try better you dumby <3 |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 17 May 2015 11:54 PM |
I still can't tell if you are seriously trying to be an idiot or not.
It is a blur to me. |
|
|
| Report Abuse |
|
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 17 May 2015 11:57 PM |
@nq
I don't think they will ever completely remove KeyDown
It will break a lot of games. New ones and classic ones. |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 11:59 PM |
| I guess they will have to keep it for idiots who don't know how to use UserInputService or ConextActionService(Hint: there is one of those idiots on this very thread.) |
|
|
| Report Abuse |
|
|
|
| 18 May 2015 12:25 AM |
| Somehow localscripts used to load before the player despite the fact that they were descendants of the player. I guess that's not a problem anymore. |
|
|
| Report Abuse |
|
|