Hey guys, so I have this module script which has an array of controls to bind
local config = {}
config.keyboardControls = {
Enum.KeyCode.One,
Enum.KeyCode.Two,
Enum.KeyCode.Three,
Enum.KeyCode.Four,
Enum.KeyCode.Five
}
config.gamepadControls = {
Enum.KeyCode.DPadLeft,
Enum.KeyCode.DPadRight,
Enum.KeyCode.DPadUp,
Enum.KeyCode.DPadDown
}
return config
I’ve been trying to pass the all the Enum.KeyCodes to the :BindAction
, method to be able to bind all of those KeyCodes to the same function.
-- Keyboard and Gamepad Listener
ContextActionService:BindAction("openSelection", showSelection, false,
unpack(config.keyboardControls), unpack(config.gamepadControls)
)
My approach to this was trying to use unpack, however, it appears only the first element of the table is passed as an argument, and the rest of the elements in the table are ignored. I was wondering if anyone knows what the most efficient solution to fixing this problem would be?