I’m currently making game settings, and I want for players to be able to change their keybinds. How do I store the keycodes?
Datastore can only accept valid UTF-8 characters and therefore cant simply accept Enum.KeyCode or anything like that.
All EnumItems have a Value number property that’s unique within that Enum group. You can store that value in a datastore. When you load data, get the original enum with Enum.KeyCode[value]
@azavier123 mentioned how to correctly get the KeyCode from that value. I was thinking about something else and got it wrong.
You can only index Enum.KeyCode like that if you store the name instead of the value, to load the enum by value there is a function:
Enum.KeyCode:FromValue(val)
Enum.Keycode has a Name property, perhaps you can save the name to the data store then do something like Enum.Keycode[storedKey]
I didn’t know there was a function to get the Keycode from Value (whoops)
You can store the name or the number. Its like KeyCode.name or something like that, thats exactly what I did for my custom keybinds system. When the game loads in create a function that decodes those back into the proper enums
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.