I was wondering if I could get some feedback on a tournament system I’m creating. My goal is to split players into brackets and go through the brackets until there is a winner. Currently, I just have start of the table based off of my outline here:
local tournament = {
--First round (all players in the server split into brackets)
[1] = {
[1] = {
"Player",
"Player"
},
[2] = { --this bracket has one player because its an odd amount in server
"Player"
}
},
--Second round (winners of first round)
[2] = {
[1] = {
"Player",
"Player"
},
}
}
Code using the outline above:
while true do
wait(10)
local tournament = {
[1] = {}
}
local players = shuffle(game:GetService("Players"):GetPlayers())
local bracket = 1
while #players > 0 do
if #players > 1 then
tournament[1][bracket] = {
table.remove(players),
table.remove(players)
}
else
tournament[1][bracket] = {
table.remove(players)
}
break
end
bracket += 1
end
for i = 1, #tournament[1] do
for _, player in pairs(tournament[1][i]) do
print("Bracket " .. i .. ": " .. player.Name)
end
end
end
I am making each index of the tournament table the round, and each index inside the round brackets. I plan on going through each bracket until there are no more brackets in that round, then advance to the next.
If there is any criticism I can get or other methods of making a tournament system, I would love to hear it.