Is there a better way I could make my dictionary go in order without having to refer to another table?
player_commands = { settings = { button_size = UDim2.new(0, 95,0, 30); max_col = 4; dir = options.players_commands; padding = 2; order = { 'Kick'; 'Kill'; 'Explode'; 'Burn'; 'Load'; 'Tp_to_me'; 'Tp_to'; } }; commands = { Kick = function() end; Kill = function() end; Explode = function() end; Burn = function() end; Load = function() end; Tp_to_me = function() end; Tp_to = function() end; } } do local col = 0 local row = 0 local count = 0 for a,b in pairs(player_commands.settings.order) do local v = player_commands.commands[b] -- Have to use this to go in order local button = create("TextButton") { Text = b; Name = b; BackgroundTransparency = (count % 2 == 0 and .3 or .5); BorderSizePixel = 0; Size = player_commands.settings.button_size; Font = "Legacy"; FontSize = "Size12"; TextColor3 = Color3.new(1,1,1); Position = UDim2.new( 0,5 + ( (player_commands.settings.button_size.X.Offset * col ) + (col * player_commands.settings.padding)) , 0,5 + ( (player_commands.settings.button_size.Y.Offset * row ) + (row * player_commands.settings.padding))); Parent = player_commands.settings.dir } row = (col + 1 == player_commands.settings.max_col and row + 1 or row) col = (col + 1 == player_commands.settings.max_col and 0 or col + 1) count = count + 1 end end
As 2eggnog said, sadly it's not possible. But you can do something like:
commands = { {"Kick"; function() end}; {"Kill"; function() end};
And so on to preserve order, but you will not be able to check if a command exists directly by key.