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 » Scripters
Home Search
 

Re: Convert string to KeyCode

Previous Thread :: Next Thread 
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
25 Aug 2016 08:39 AM
I made a system to change keybindings in roblox and I want to save your settings, however, you can't save Enums. So I have the idea to just convert it into a string and then save it, but I have no idea how to convert it back once you load it in again.
Anyone got an idea on how I could do this?
Report Abuse
Laedere is online. Laedere
Joined: 17 Jun 2013
Total Posts: 23601
25 Aug 2016 08:40 AM
Maybe Enum.KeyCode["String"]


Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
25 Aug 2016 08:43 AM
print(input.KeyCode == Enum.KeyCode[keystring])
This prints true, so I think it will work, thanks!
Report Abuse
Objectly is not online. Objectly
Joined: 18 Jul 2016
Total Posts: 210
25 Aug 2016 08:44 AM
Save your string values in a dictionary with [string] = enum or you can have a dictionary that has the strings as indexes with the enums that you can access whenever you want those enums.
Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
25 Aug 2016 08:50 AM
^
I wanted to save those enums to datastores, and datastores can only save numbers, strings and tables, so that's why I needed to convert them. Also, I'm still not sure if you can save dictionnaries, but I know that I've had a lot of trouble with them in the past, so I'm using regular tables :)
Report Abuse
Objectly is not online. Objectly
Joined: 18 Jul 2016
Total Posts: 210
25 Aug 2016 08:52 AM
You can have a module that stores the enums instead of a datastore.
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
25 Aug 2016 08:55 AM
Dictionaries and arrays and mixed keys are all "regular tables". Regular tables are more a general term for when you don't know what the table contains for keys. They're all data structures. As for if you were having issues it was likely 100% an issue you could of worked around. ###p://wiki.roblox.com/index.php?title=Data_store#Tables_with_mixed_list_.2F_record_style_will_be_cut_off
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
25 Aug 2016 08:56 AM
*A table is just the general term; doesn't matter what the table contains for keys
Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
25 Aug 2016 09:00 AM
Yeah, at the time I was struggeling with these, I've been on the wiki searching for a long time, reread the whole thing a couple of times because I really wasn't sure what I was doing wrong... However, I don't need a dictionnary now, a table with numbers as keys is sufficient.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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