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 to check if a key is down

Previous Thread :: Next Thread 
WilhelmP is not online. WilhelmP
Joined: 27 Aug 2014
Total Posts: 28
18 Aug 2016 07:01 AM
i wnat to make a game but i cant find how to check if a player is pressing a key. everything i have tried didnt work. please help me.
Report Abuse
Badandy11 is not online. Badandy11
Joined: 02 Jul 2009
Total Posts: 1861
18 Aug 2016 08:20 AM
http://wiki.roblox.com/index.php?title=API:Class/UserInputService/IsKeyDown

This would have to be in a loop since it's a function
Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 09:13 AM
gj badandy u beat me to it.
Report Abuse
WilhelmP is not online. WilhelmP
Joined: 27 Aug 2014
Total Posts: 28
18 Aug 2016 11:59 AM
were do you set the key and how do you take the output?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
18 Aug 2016 12:02 PM
--local script inside playergui

local uis = game:GetService('UserInputService')

uis.InputBegan:connect(function(input,event)
if event then return end --we dont want something to happen if the player is typing
if input.KeyCode == Enum.KeyCode.E then
print('Pressing E')
end
end)

http://wiki.roblox.com/?title=API:Class/UserInputService
http://wiki.roblox.com/?title=API:Enum/KeyCode


Report Abuse
WilhelmP is not online. WilhelmP
Joined: 27 Aug 2014
Total Posts: 28
18 Aug 2016 12:17 PM
i dont know if im doing wrong or what but its not working. :(
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
18 Aug 2016 12:18 PM
need to be in a local script inside screengui/playergui


Report Abuse
WilhelmP is not online. WilhelmP
Joined: 27 Aug 2014
Total Posts: 28
18 Aug 2016 12:21 PM
i did press play in roblox studio. under the players/my name/playergui i put a localscript with your code. then i pressed e but it didnt say e in the console. am i doing something wrong?(what)
Report Abuse
superpants2020 is not online. superpants2020
Joined: 10 Feb 2013
Total Posts: 804
18 Aug 2016 12:37 PM
put it in workspace


i like ducks bro. deal wit it.
Report Abuse
WilhelmP is not online. WilhelmP
Joined: 27 Aug 2014
Total Posts: 28
18 Aug 2016 12:39 PM
workspace or player gui?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
18 Aug 2016 12:40 PM
@super you dont put it in workspace *facepalm*


Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 12:41 PM
Bro put it in a local script in workspace. I don't know why he said PlayerGui but that is not necessary
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
18 Aug 2016 12:43 PM
https://gyazo.com/22d625cf562d1a7b7aa37037c894629f


Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 12:44 PM
You can put it in there but still lets end the confusion and put it in workspace where you can always see it.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
18 Aug 2016 12:45 PM
Wright. You're just a moron. I'm done trying to rationalize with you.


Report Abuse
TilloFernandez is not online. TilloFernandez
Joined: 21 Mar 2015
Total Posts: 273
18 Aug 2016 12:47 PM
When noobs find Roblox.

Also, LocalScripts won't run if they're not a descending parent of 'Player'.
Scripts will only run in a descending parent of 'Player', 'Workspace', or 'ServerScriptService'.

The ignorance here is uncomprehendable (Yes, I just made a new word).


~ The Lonely Developer
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
18 Aug 2016 12:49 PM
incomprehensible *


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
18 Aug 2016 12:49 PM
"Bro put it in a local script in workspace."

sleeeep

stop giving misinformation
Report Abuse
WilhelmP is not online. WilhelmP
Joined: 27 Aug 2014
Total Posts: 28
18 Aug 2016 12:55 PM
thanks 4 the help. it works now after the gif from @TimeTicks becouse i
thought it wasi the playergui like you said and not in the starter gui. :D
Report Abuse
Badandy11 is not online. Badandy11
Joined: 02 Jul 2009
Total Posts: 1861
18 Aug 2016 12:55 PM
Do people even read the wiki anymore? -_-
Report Abuse
superpants2020 is not online. superpants2020
Joined: 10 Feb 2013
Total Posts: 804
18 Aug 2016 12:55 PM
oh wait nvm playergui is only on the client so u need to do it ig i believe.


i like ducks bro. deal wit it.
Report Abuse
Badandy11 is not online. Badandy11
Joined: 02 Jul 2009
Total Posts: 1861
18 Aug 2016 12:57 PM
.... When the player joins the game, everything in StarterGui goes into PlayerGui
Report Abuse
WilhelmP is not online. WilhelmP
Joined: 27 Aug 2014
Total Posts: 28
18 Aug 2016 01:01 PM
ok
Report Abuse
hephzibah112 is not online. hephzibah112
Joined: 21 Sep 2012
Total Posts: 327
18 Aug 2016 01:04 PM
Create a tool, put a part in the tool and name it "Handle". Insert a localscript into the tool.

Copy and paste > into localscript

player = game.Players.LocalPlayer


tool = script.Parent

tool.Equipped:connect(function(mouse)

mouse.KeyUp:connect(function(key) -- Either change Up, or Down."KeyUp"-"KeyDown"

if key == "h" then -- When you press h in game(playersolo)
print 'you released h'
else
print 'why did you not release me'
end
end)
end)




Report Abuse
Badandy11 is not online. Badandy11
Joined: 02 Jul 2009
Total Posts: 1861
18 Aug 2016 01:13 PM
@hephzibah112

Just use the UserInputService
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