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
 

Re: How use UserInputService?

Previous Thread :: Next Thread 
WhatsItName is not online. WhatsItName
Joined: 29 Jun 2009
Total Posts: 166
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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
17 May 2015 11:19 PM
wiki.roblox.com
Report Abuse
WhatsItName is not online. WhatsItName
Joined: 29 Jun 2009
Total Posts: 166
17 May 2015 11:20 PM
I tryed that it isn't there, just for the decriyptated KeyPressed
Report Abuse
TimeTicks is not online. 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 is not online. 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
WhatsItName is not online. WhatsItName
Joined: 29 Jun 2009
Total Posts: 166
17 May 2015 11:23 PM
thx @time

thx @amanda
Report Abuse
mycheeze is not online. 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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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 is not online. 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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
17 May 2015 11:40 PM
Also, there are reasons to use RemoteEvents/functions with FE disabled.
Report Abuse
mycheeze is not online. 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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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 is not online. 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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
17 May 2015 11:50 PM
Still shorter to use ContextActionService anyways.
Report Abuse
mycheeze is not online. 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 is not online. 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 is not online. 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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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
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