Hey, I'm not quite sure if i'm allowed to post this here but. I'm having trouble understanding this script. You see I want to use more of this - but i have no clue what it does here is the script
` local teams do
teams = { }
local allTeams = game:GetService("Teams"):GetChildren()
for i = 1, #allTeams do
teams[allTeams[i].Name] = allTeams[i]
end
end`
Can anyone help?
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.