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
|
  |
| 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 |
|
|
|
| 18 Aug 2016 09:13 AM |
| gj badandy u beat me to it. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 18 Aug 2016 12:37 PM |
put it in workspace
i like ducks bro. deal wit it. |
|
|
| Report Abuse |
|
|
WilhelmP
|
  |
| Joined: 27 Aug 2014 |
| Total Posts: 28 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 18 Aug 2016 12:40 PM |
@super you dont put it in workspace *facepalm*
|
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 18 Aug 2016 12:43 PM |
https://gyazo.com/22d625cf562d1a7b7aa37037c894629f
|
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
|
| 18 Aug 2016 12:49 PM |
"Bro put it in a local script in workspace."
sleeeep
stop giving misinformation |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 02 Jul 2009 |
| Total Posts: 1861 |
|
|
| 18 Aug 2016 12:55 PM |
| Do people even read the wiki anymore? -_- |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 27 Aug 2014 |
| Total Posts: 28 |
|
| |
|
|
| 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
|
  |
| Joined: 02 Jul 2009 |
| Total Posts: 1861 |
|
|
| 18 Aug 2016 01:13 PM |
@hephzibah112
Just use the UserInputService |
|
|
| Report Abuse |
|
|