GetTeams (Method): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>MrNicNac
Added an example.
>ArceusInator
better example (imo)
Line 11: Line 11:
{{Example|This is an example of using the method above to get all the teams and remove them. Includes the generic for loop.
{{Example|This is an example of using the method above to get all the teams and remove them. Includes the generic for loop.
<pre>
<pre>
local TeamTable = Game:GetService("Teams"):GetTeams()
local teams = Game:GetService("Teams"):GetTeams()


for i,k in pairs(TeamTable) do
if type( teams ) == "table" then
   k:Remove()
  print( "There are " .. #teams .. " teams." )
  print( "They are as follows:" )
  for i = 1, #teams do
      print( "Team " .. i .. ": " .. teams[i].Name )
   end
else
  print( "There are no teams!" )
end
end
</pre>
</pre>
}}
}}


[[Category:Methods]]
[[Category:Methods]]

Revision as of 21:37, 13 January 2011

GetTeams( )
Returns Table teams
Description: Returns a table of all of the teams.
Member of: Teams


Example
This is an example of using the method above to get all the teams and remove them. Includes the generic for loop.
local teams = Game:GetService("Teams"):GetTeams()

if type( teams ) == "table" then
   print( "There are " .. #teams .. " teams." )
   print( "They are as follows:" )
   for i = 1, #teams do
      print( "Team " .. i .. ": " .. teams[i].Name )
   end
else
   print( "There are no teams!" )
end