You don't have to use table.insert in Execute snippets, you can just `button[i] = ...`.
I think you have a flaw in the inner for cycle:
Lua Code:
for j = 1, 6 do
if not overridebuttons[i]:GetAttribute('statehidden') then
buttons[j]:SetAttribute('statehidden', false)
buttons[j]:Show()
else
buttons[j]:SetAttribute('statehidden', true)
buttons[j]:Hide()
end
end