How to use Unpack()?

Hey I’m trying to create a keybind system for my game and I have all of my binds stored in a table like so:

["Keyboard&Mouse"] = {
		["Sprint"] = {
			Enum.KeyCode.LeftShift,
			Enum.KeyCode.LeftControl,
			nil,
		},
	},
	["Gamepad"] = {
		["Sprint"] = {
			Enum.KeyCode.ButtonR2,
			Enum.KeyCode.Thumbstick1,
			nil,
		},
	},

I’m using ContextActionService to create my actions, but I don’t know how to efficiently ‘unpack’ all of them from my list. I’ve tried using unpack() but It only works for the first value in the list.

ContextActionService:BindAction("Sprint", onSprintInput, true, unpack(keyboardMouseBinds["Sprint"]), unpack(gamepadBinds["Sprint"]))

Any help would be appreciated, thank you!

ContextActionService:BindAction("Sprint", onSprintInput, true, ...)
the last argument is vararg, normally, you can fit in unpack(keyboardMouseBinds["Sprint"]) and it will take all of the values. however, it only works if the unpacked values is used as the final vararg argument.
since you wrote unpack(keyboardMouseBinds["Sprint"]), unpack(gamepadBinds["Sprint"]), the first unpacked list is not the ‘final’ argument anymore, so it cut short to 1 value. and then the next unpacked list don’t get processed because the vararg think it got that 1 value already.
so overall it is just 1 value being passed in.

we have to go the long way to combine two arrays into one first

local t1 = keyboardMouseBinds["Sprint"]
local t2 = gamepadBinds["Sprint"]
local t3 = {}
for i, v in pairs(t1) do
    table.insert(t3, v)
end
for i, v in pairs(t2) do
    table.insert(t3, v)
end

ContextActionService:BindAction("Sprint", onSprintInput, true, unpack(t3))