|
| 25 Apr 2015 05:17 PM |
So I'm using this script to determine how many players on a team. It works fine, except that when the number of people on either one of the two teams changes, the script does not react like I want it to.
Here's the script
local team = game.Teams;
function getPlayers(teamColor) local found = { }; for _,v in pairs(game.Players:GetPlayers()) do if v.TeamColor == teamColor then table.insert(found, v) end end return #found end
while wait() do local greenNum = getPlayers(BrickColor.new('Bright green')) local redNum = getPlayers(BrickColor.new('Bright red')) if greenNum > 0 and redNum > 0 then print('Enough players') else print('Not enough players') end end
|
|
|
| Report Abuse |
|
|
tecno15
|
  |
| Joined: 10 Sep 2009 |
| Total Posts: 1372 |
|
|
| 25 Apr 2015 05:19 PM |
a while wait() loop
how adorable |
|
|
| Report Abuse |
|
|
|
| 25 Apr 2015 05:20 PM |
| Well how do you want it to react? |
|
|
| Report Abuse |
|
|
|
| 25 Apr 2015 05:25 PM |
When it detects that there is 0 players on one or the other team (or both), it prints "Not enough players"
I want the script to do is detect if the number of players on the team changes, and if it does, to both teams having a minimum of one player, I want it to print "Enough players" |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Apr 2015 08:07 PM |
wiki.roblox.com/index.php?title=Teams#Events ChildAdded and ChildRemoved might be of help here |
|
|
| Report Abuse |
|
|
|
| 25 Apr 2015 11:19 PM |
| The script works fine, I just need it to react when values change |
|
|
| Report Abuse |
|
|
| |
|
acidflip
|
  |
| Joined: 18 Jul 2012 |
| Total Posts: 886 |
|
|
| 26 Apr 2015 10:37 AM |
> "The script works fine, I just need it to react when values change"
and this is how you do that: http://www.roblox.com/Forum/ShowPost.aspx?PostID=160960403#160946451 |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|