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 » Game Design
Home Search
 

Re: Custom Keybinds with UserInputService?

Previous Thread :: Next Thread 
hempants15 is not online. hempants15
Joined: 22 Jul 2011
Total Posts: 153
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
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
29 Dec 2016 08:01 PM
if input.KeyCode == "Your key here" then
--Do something
end
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
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
hempants15 is not online. hempants15
Joined: 22 Jul 2011
Total Posts: 153
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
hempants15 is not online. hempants15
Joined: 22 Jul 2011
Total Posts: 153
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
hempants15 is not online. hempants15
Joined: 22 Jul 2011
Total Posts: 153
30 Dec 2016 05:02 PM
Anyone have a better way?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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