local TableOfTeams = {
Blue Team = 1,
Red Team = 3,
Green Team = 2,
Yellow Team = 1
}
How would I get the team with the lowest value? I’ve done some research and I do know about math.min, but the problem is, is that I need to get the team name too.
I basically need it to find the team with the lowest value, and then return the team name.
I’ve been struggling with this so if you help, thanks in advance
local TableOfTeams = {
["Blue Team"] = 1,
["Red Team"] = 3,
["Green Team"] = 2,
["Yellow Team"] = 1
}
local smallestTeam, smallestScore
for team, score in TableOfTeams do
if not smallestTeam or score < smallestScore then
smallestTeam = team
smallestScore = score
end
end