|
| 29 Dec 2016 07:59 PM |
I know this is how you get input from a Player now: (Example)
if input.KeyCode == Enum.KeyCode.E then print("blah") end
(Example) But, I want the player to be able to choose what key he/she wants to use to print blah. I have a datastore set up to save the string of the key the player chooses. How would I use the string value to set what KeyCode it is? For example, before you would be able to do this: (Example)
If Key == ChosenKey.Value then print("blah") end --ChosenKey is a stringvalue (Example) |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2016 08:01 PM |
if input.KeyCode == "Your key here" then --Do something end |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2016 08:02 PM |
| I've never tried that before but it might work. It works like that for other Enums. |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2016 08:18 PM |
It didn't work, I tried:
if input.KeyCode == "E"
and
if input.KeyCode == "e"
to see if it could use a string, but when I pressed e nothing happened. No errors either. |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2016 10:19 PM |
I figured out a way to do it, but I feel it is inefficient and long. (Example)
UserKey = nil
if Player.Data.CustomKey.Value == "H" then
UserKey = Enum.KeyCode.H end
if input.KeyCode == UserKey then print("blah") end (Example)
You would have to do this for every key on the keyboard.
If anyone has a better answer please post it. |
|
|
| Report Abuse |
|
|
| |
|