When you're using a dictionary, the index is no longer "1", "2", "3", "4", etc. As your output shows, it's now "Pink", "Purple", "Blue", etc. Unfortunately, you can't sort that in order.
"in pairs" doesn't care about the order of the indices, whereas "ipairs" does. You can't use "ipairs" on a dictionary.
One approach if you absolutely must have red come before blue is to simply have two tables and have their values match their indices so index 1 of one table corresponds to index 1 of another table.
02 | BrickColor.new( "Bright red" ), |
03 | BrickColor.new( "Bright blue" ) |
10 | function AddTeams(numberOfTeams) |
11 | if type (numberOfTeams) = = "number" then |
14 | for i,v in pairs (TeamColors) do |
15 | if (number > numberOfTeams) then return end |
16 | print ( "Index:" .. i, "Value:" .. tostring (v)) |
18 | local team = Instance.new( "Team" , game:WaitForChild( "Teams" )) |
19 | team.Name = teamNames [ i ] |
I edited that quickly so it might have some problems, but if it was helpful please upvote/mark correct, and if you have any questions or if I messed up please comment below.