This isn’t a “how to make custom keybinds” question, this is a “Which of the listed methods is better” question;
A. have a dictionary, where:
- Key = keybind,
- Value = bindable event
and then whenever a key is pressed, loop through that dictionary and see if the key pressed is equal to one of the keys in the dictionary, if yes, fire the event
an example of this would be:
local keyActions = {
["LeftControl"] = BindableEventInstance,
-- and so on
}
local function OnInput(input: InputObject)
for key, bindableEvent in keyActions do
if input.KeyCode == key then bindableEvent:Fire() end
-- can someone tell me if that if statement is written correctly lol
end
end
this would result in all action invoking to be in the same script, while the action handling can stay independent
B. independently check the key in an action-handling script
rather than having a seperate script that invokes actions, all the actions would already be checking if the key is correct, for example;
local playerKeybinds = require(something)
local function OnInput(input: InputObject)
if input.KeyCode == playerKeybinds[actionName] then
-- perform actions, yes i know the if statement above will error,
-- but it's just an example
end
end