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: Teams

Previous Thread :: Next Thread 
Kasumo is online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
25 Jul 2014 01:54 PM
How do I get how many players are on the team when gT hits 0? And the team with the most players in it wins?

if (gT.Value == 0) then
p[i].Character.Humanoid.Health = 0
--Instance.new("Message",game.Workspace).Text = " team has won!"--
end
end
Report Abuse
Kasumo is online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
25 Jul 2014 02:09 PM
bump
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
25 Jul 2014 02:11 PM
You could try using something such as,
TeamCount = 0
for _,v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == game.Teams.TeamNameHere.TeamColor then
TeamCount = TeamCount+1
end
end
Report Abuse
Kasumo is online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
25 Jul 2014 02:21 PM
?
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
25 Jul 2014 02:32 PM
The script loops through the Player's table and increases the numerical value of the variable "TeamCount" for each player matching the team's TeamColor.

You could create two separate variables for each team and then use conditional statements to compare the resulting value of both variables.
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
25 Jul 2014 02:39 PM
-- I made this earlier today for a different question.

_G.GetPlayersOnTeam = function(name)
local plrs = {};
if(game.Teams:FindFirstChild(name)) then
local team = game.Teams[name];
for index,value in next,game.Players:GetPlayers() do
if(value.TeamColor == team.TeamColor) then
table.insert(plrs, value);
end
end
end
end

USAGE FROM ANY SCRIPT

print(tostring(#_G.GetPlayersOnTeam("team name here")));

USAGE TO GET PLAYERS FROM ANY SCRIPT TO OUTPUT

print(unpack(_G.GetPlayersOnTeam("team name here")));
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
25 Jul 2014 02:43 PM
-- Oh, and usage in this specific case :
repeat wait() until gT.Value == 0;
numplayers = tostring(#_G.GetPlayersOnTeam("team name here"));
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 Jul 2014 02:47 PM
@KOT and what if the script uses the _G function before the script that creates the _G function loads?

Uh oh *game breaks*
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
25 Jul 2014 02:47 PM
#TEAM:GetChildren()
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 Jul 2014 02:48 PM
@sens

It what world would that work?
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
25 Jul 2014 02:50 PM
@war; no clue why people keep saying #TEAM:GetChildren().
ever since you left, this place has been filled with trolls.
and good point about the game breaking thing.

this is a signature: pcall(function() print([[apparently this is a string]]) end)
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
25 Jul 2014 02:53 PM
GetChildren() returns a table

#table = number
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 Jul 2014 02:54 PM
"ever since you left"

When'd I leave? XD

Yea #TEAM:GetChildren() is like the worst attempt ever.
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
25 Jul 2014 02:57 PM
@sen; the players aren't stored within the team.
*facedesk*

this is a signature: pcall(function() print([[apparently this is a string]]) end)
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
25 Jul 2014 02:58 PM
Damn I just realized that
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 Jul 2014 03:10 PM
XD
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