Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I cant use Enum.KeyCode?

Asked by 5 years ago

How to use KeyCode? I wanted to make a script when you press E the text on the GUI changes

0
You suck L0cal_Scr1pt 34 — 5y
0
no u HTHRWRU 6 — 5y
0
Hey, just asking if you know that Enum.KeyCode is for controller support, not for keyboard support. Also please don't post requests. -FrumosUniverse superawesome113 112 — 5y
0
umm then what do i use? HTHRWRU 6 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Do not listen to superawesome113. He is wrong. KeyCode is an Enum specifically designed for keyboards and keyboard input. (Controllers also have KeyCodes, but their KeyCodes are of less priority than keyboard KeyCodes.)

KeyCode would usually be used with the UserInputService, a client side only service that is used to receive input (hence its name). For detecting the letter E, that would be Enum.KeyCode.E.

For using KeyCode, the UserInputService's InputBegan event passes two parameters for this, the first being the input received. You can check if that input was keyboard input using the keyboard's UserInputType Enum. Then you can use input.KeyCode to find what KeyCode was received.

That's basically how you use KeyCode.

0
Can i get an example? HTHRWRU 6 — 5y
0
if input.KeyCode == Enum.KeyCode.E then DeceptiveCaster 3761 — 5y
0
thx HTHRWRU 6 — 5y
Ad

Answer this question