|
| 11 Feb 2017 03:23 PM |
I need to wait for a certain key to be pressed without using --
function keydown(key) if key == "a" then run() end end
-- I want to use something more like using the :Wait() function, such as --
(code to determine if A is pressed):Wait()
-- suggestions?
|
|
|
| Report Abuse |
|
|
Wrathsong
|
  |
| Joined: 05 Jul 2012 |
| Total Posts: 22393 |
|
|
| 11 Feb 2017 03:23 PM |
UserInputService
Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow me on twitch: twitch.tv/austinrblx |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Feb 2017 03:27 PM |
Would it be:
wait(IsKeyDown('a'))
or
IsKeyDown('a'):Wait() |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:28 PM |
Something like
Mouse.KeyDown:connect(function(Key) if Key == "a" then run() end end)
also if you're wondering about the Mouse: - Mouse = plr:GetMouse() and plr would be - plr = game.Players.LocalPlayer |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:29 PM |
| As stated I do not want to use a function, I want to use a :Wait() |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:29 PM |
local key; repeat key = Mouse.KeyDown:wait() until key == "a"
|
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:32 PM |
| this looks correct, I will try it |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:32 PM |
dont use keydown
also
repeat user_input_service.InputBegan:wait() until user_input_service:IsKeyDown(Enum.KeyCode.A) |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Feb 2017 03:33 PM |
| if you use keydown wont function online, deprecated, use my example, plus the wait is more exact |
|
|
| Report Abuse |
|
|
Wrathsong
|
  |
| Joined: 05 Jul 2012 |
| Total Posts: 22393 |
|
|
| 11 Feb 2017 03:37 PM |
use wunder's example
Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow me on twitch: twitch.tv/austinrblx |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:37 PM |
You sir are completely and utterly autistic.
KeyDown works online. The wait is LESS exact and that also might not detect it because RBX.Lua is slow and you're using IsKeyDown. Your method is also less efficient because you're calling a function every time they press a key whereas I'm only comparing a string value.
All in all, KeyDown is better in every way shape or form except that ROBLOX won't let you receive certain characters.
|
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:38 PM |
| mine has a more exact wait because it checks as soon as a key is pressed so it is more efficient |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:39 PM |
| plus it wont lag your scripts if you use multiples of them due to them constantly looping and using that function when they shouldnt be |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 03:42 PM |
You're doing the exact same thing, but instead you're using InputBegan which actually is fired by both mouse and keyboard. You're also doing it in a less efficient manner. For all intents and purposes, Mouse.KeyDown is a better and cleaner method of doing it, the only downside is that you cannot attach it to numbers, and that ROBLOX doesn't like it.
www.youtube.com/watch?v=-NuONuafxwk
|
|
|
| Report Abuse |
|
|