|
| 09 Nov 2012 11:10 PM |
| roblox gui to display number of people on each team |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2012 11:15 PM |
TeamColor = 'Team Color Here';
Teams = Game:GetService('Teams'); function get() local num = 0; for _, v in pairs(Game.Players:GetPlayers()) do if v.TeamColor == BrickColor.new(TeamColor) then num = num + 1; end end return num; end
script.Parent.Text = get(); |
|
|
| Report Abuse |
|
|
| |
|
|
| 09 Nov 2012 11:27 PM |
1.) Where did you place the script 2.) Do you have a team in the game 3.) Did you enter that team color into the script |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2012 11:28 PM |
It works. But how would I make it dynamic so here is what I am tying to do :
Team A > [0] Team B > [0]
Dynamic meaning is someone leaves or joins that other team the other one will update. |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2012 11:40 PM |
Try this out.
TeamColor = 'Team Color Here'; Teams = Game:GetService('Teams'); TeamPlayers = {};
function numChanged() script.Parent.Text = #TeamPlayers; end
function watch() for _, plr in pairs(Game.Players:GetPlayers()) do if plr.TeamColor == BrickColor.new(TeamColor) and not TeamPlayers[plr] then table.insert(TeamPlayers,plr); numChanged(); plr.Changed:connect(function(property) if property == 'TeamColor' and plr.TeamColor ~= BrickColor.new(TeamColor) then TeamPlayers[plr] = nil; numChanged(); end end) end end Game.Players.PlayerAdded:connect(function(plr) wait(); if plr.TeamColor == BrickColor.new(TeamColor) and not TeamPlayers[plr] then table.insert(TeamPlayers,plr); numChanged(); end end) end
watch(); numChanged();
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2012 12:02 AM |
--Over complicated, and could probably be shortened. Oh well, works fine.
team1Table = {} team2Table = {} team1 = game:GetService("Teams").Team1 team2 = game:GetService("Teams").Team2 Team1Count = 0 Team1Count = 0
function GetCount() p = game.Players:GetChildren() for i = 1, #p do if p[i].TeamColor == team1.TeamColor then table.insert(team1Table,1,p[i]) elseif p[i].TeamColor == team2.TeamColor then table.insert(team2Table,1,p[i]) end end for i,v in pairs(team1Table) do if v then Team1Count = Team1Count + 1 end end for i,v in pairs(team2Table) do if v then Team2Count = Team2Count + 1 end end end
function PlayerRemoved(player) for i = 1, #team1Table do if player.Name == team1Table[i].Name then table.remove(team1Table,1,player) Team1Count = Team1Count - 1 end end for i = 1, #team2Table do if player.Name == tabm2Table[i].Name then table.remove(team1Table,1,player) Team2Count = Team2Count - 1 end end end
game.Players.PlayerAdded:connect(GetCount) game.Players.ChildRemoved:connect(PlayerRemoved) |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2012 04:46 PM |
@LUVMARIOLUIGI10000 His worked fine for my game. Stop looking for attention and trying to act 'Smart'. |
|
|
| Report Abuse |
|
|
Rukiryo
|
  |
| Joined: 04 Sep 2009 |
| Total Posts: 1490 |
|
|
| 10 Nov 2012 04:56 PM |
No kidding lol. "So inefficient, oh well" LOL. You can act smart when you program a real language. Lua is a baby scripting language. You still can't call yourself a programmer for using it. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2012 05:02 PM |
| Im not looking for attention, nor trying to look smart. It's a scripting helpers forum, you posted a question and I simply answered with a chunk of code. And @Rukiryo, I never called myself a programmer, nor smart. |
|
|
| Report Abuse |
|
|
Rukiryo
|
  |
| Joined: 04 Sep 2009 |
| Total Posts: 1490 |
|
|
| 10 Nov 2012 05:06 PM |
You said "oh well" as if you would put up with it even though you were 'so above it'. So yes, you did try to act smart. If you are mature enough, you'll accept it and let this thread die. Go fight somewhere else, troll. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 10 Nov 2012 07:49 PM |
YEs it is...
his main got banned he made a new account..
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2012 08:05 PM |
| lol it is jared. His game is on front page too, I think he copied quenty's? |
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Nov 2012 08:37 PM |
| @Rukiryo, I said 'Oh well', because it was a messy code that was too long and over complicated, that's why I said 'Oh well, it still works.' I never tried to act smart, and it is efficient, just because it doesn't meet your standards doesn't mean it's 'inefficient'. And I don't need to insult other people by calling them 'trolls' to make myself feel better. Once again I said 'Oh well', becuase I know it's a messy and sorta bad code. |
|
|
| Report Abuse |
|
|
Lapwn
|
  |
| Joined: 03 Jun 2012 |
| Total Posts: 5975 |
|
|
| 10 Nov 2012 08:40 PM |
| Your both morons for letting Jared trick you into turning against each other |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2012 08:40 PM |
| I apolagize if I made it seem that way, honestly I could do better then that, but I said that because I understood it was bad. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2012 08:55 PM |
"@LUVMARIOLUIGI10000 His worked fine for my game. Stop looking for attention and trying to act 'Smart'."
"No kidding lol. "So inefficient, oh well" LOL. You can act smart when you program a real language. Lua is a baby scripting language. You still can't call yourself a programmer for using it."
"You said "oh well" as if you would put up with it even though you were 'so above it'. So yes, you did try to act smart. If you are mature enough, you'll accept it and let this thread die. Go fight somewhere else, troll."
What is both your problems? Last I checked this was a forum for helping. Both of them helped. I know I for one enjoy trying to come up with my own solutions for solved problems. Calm down.
@Ruk
Don't even for a SECOND imply that you're smarter than or above LUVMARIO, because you really aren't. These posts you made pretty much proved that. You tell LUVMARIO that he isn't "mature enough" when you make these comments yourself? Stop throwing your little tantrums and grow up. If you can't be nice and help, just go away. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2012 08:55 PM |
@LUV
Don't apologize. Nobody here deserves an apology except you. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2012 09:02 PM |
| @Agent, thank you. Atleast someone can undertsnad my position on this. |
|
|
| Report Abuse |
|
|
| |
|