generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: I want to count the members in a team, would I do:

Previous Thread :: Next Thread 
rp069 is not online. rp069
Joined: 22 Apr 2011
Total Posts: 6206
31 May 2012 09:31 PM
i=game.Teams.Azuria:GetChildren()

if [i] = < 3 do
game.Workspace.Message.Text = "There must be at least 3 Azuria members for a riad to count!"
elseif [i] = > 3 do
game.Workspace.Message.Text = "Raids count! don't let them win Azuria!"
end
end

if it isn't, fixes?
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
31 May 2012 09:33 PM
I made a function to count the members on a team given the team's color.

function CountOnTeam(TeamColor)
local Count = 0
for Index, Player in pairs(game.Players:GetPlayers()) do
if Player.TeamColor == TeamColor then
Count = Count + 1
end
end
return Count
end
Report Abuse
rp069 is not online. rp069
Joined: 22 Apr 2011
Total Posts: 6206
31 May 2012 09:36 PM
so I would do something like

function CountOnTeam(TeamColor)
local Count = 0
for Index, Player in pairs(game.Players:GetPlayers()) do
if Player.TeamColor == TeamColor then
Count = Count + 1
if Count == > 3 do
game.Workspace.Message.Text = "Raids count! don't let them win Azuria!"
end
if Count == < 3 do
game.Workspace.Message.text = "There must be at least 3 Azuria members for a raid to count"
end
end
end
return Count
end

or am I doing that wrong?
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
31 May 2012 09:37 PM
if CountOnTeam(BrickColor.new("Team Color here")) =< 3 do
game.Workspace.Message.Text = "There must be at least 3 Azuria members for a riad to count!"
elseif [i] = > 3 do
game.Workspace.Message.Text = "Raids count! don't let them win Azuria!"
end
end
Report Abuse
rp069 is not online. rp069
Joined: 22 Apr 2011
Total Posts: 6206
31 May 2012 09:38 PM
ah, thanks dude!
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
31 May 2012 09:57 PM
This would do the same thing as the CountOnTeam function, except without the color specified.

    print(#game.Teams.Team:GetChildren())

----------
    ~pwnedu46, wiki writer~
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
01 Jun 2012 06:13 PM
@pwnedu

I don't think so, the Team objects don't appear to have children, even when players are assigned to them.
Report Abuse
thane1326 is not online. thane1326
Joined: 08 Apr 2009
Total Posts: 867
01 Jun 2012 06:16 PM
I dont know if this will work or not but...
local children = game.Players:GetChildren()
local number = #children
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image