Array dependent on bool value?

Hi,
I am wanting to have an array like the one below, but i would like four and five to be only included if a data store bool is true, can this be done?

local inputKeys = {
	["One"] = {txt = "1"},
	["Two"] = {txt = "2"},
	["Three"] = {txt = "3"},
	["Four"] = {txt = "4"},
	["Five"] = {txt = "5"},
}

local inputOrder = {
	inputKeys["One"],inputKeys["Two"],inputKeys["Three"],inputKeys["Four"],inputKeys["Five"],
}

Not sure what you mean, can you elaborate?

yes sorry I perhaps didn’t explain it very well. Basically i am found a hotbar gui that replaces the backpack default gui. It comes with five tool slots and works well. However i would like to limit that amount to two or three until some condition is met which i was planning on using a bool value to store the condition and then hoping there is a way to enable the four and five tool slots.

I tried doing

local inputKeys = {}
local B1 = true
if B1 == true then
	local inputKeys = {
		["One"] = {txt = "1"},
		["Two"] = {txt = "2"},
		["Three"] = {txt = "3"},
		["Four"] = {txt = "4"},
		["Five"] = {txt = "5"},
	}
else
	local inputKeys = {
		["One"] = {txt = "1"},
		["Two"] = {txt = "2"},
		["Three"] = {txt = "3"},
	}
end

but the script seems to ignore it completely

That’s working, you just need to remove the local before the inputKeys in your condition ( keep it on the first line of course)

2 Likes

Yeah just noticed i had defined them more than once, thanks.