✓ Accepted answer
Assign the variable "teams" to an empty array
teams = {}
Store all the instances inside of the Teams service into an array
local allTeams = game:GetService(“Teams”):GetChildren()
Loop through the indexes of the "allTeams" array. If there are five, the there are five indexes.
for i = 1, #allTeams do
Append a new team like a dictionary (key, element) into the teams array
The key would be the teams name
the element would be the contents inside the team, aka the players
teams[allTeams[i].Name] = allTeams[i]
tl;dr
It re-formats the way of accessing the individual instances in each team
Instead of doing:
game:GetService("Teams")["TeamName"]["Player"]
It is now done like:
teams["TeamName"]["Player"]
Personally it seems pretty useless since you can just do:
teams = game:GetService("Teams")
teams["TeamName"]["Player"]
and it would have the same effect. But that's only from a basic perspective, there may be other treats to this method that I cannot see at the moment.
1 comment
It inserts all teams to a dictionary table.