Hey!
I’m working on a system that allows players to customize their keybindings for various in-game actions in my Roblox game. To achieve this, I plan to use DataStoreService to save these keybinding preferences. However, I’ve encountered a hurdle – I can’t seem to save Enums like Enum.KeyCode.E .
So I’ve been exploring various solutions, and here’s what I’ve come up with:
I’ve been using ContextActionService to bind actions, and I noticed that when I bind an action with no keys, like this:
ContextActionService:BindAction("Action1", actionFunction, true, nil)
I get this error:
ContextActionService:BindAction called with an invalid hotkey (should be either Enum.KeyCode, Enum.UserInputType, or string)
This error message suggests that I can bind a key using a string, right? Since strings can be saved in DataStore, I decided to experiment with it. Some strings like “e,” “w,” and “h” seem to work:
ContextActionService:BindAction("Action1", actionFunction, true, "e", "w", "h")
However, my question is: Is there a comprehensive list of strings that are valid for binding keys using ContextActionService? I’ve looked through the ContextActionService documentation, but I couldn’t find such a list. I’d like to know if this approach is a viable solution for my keybinding customization system or if there’s a better method out there.
Does anyone have insights or know where I can find this information?
Thank you for your help!