How can I make a GUI that counts how many players are in each team?

Hello everyone. Hope you having a great day.

I don’t want the normal leaderboard so I want to make a GUI that only shows a number of how many people are in that team.
For example a gui that is a red box that shows of how many players are in the red team, and the same thing for the other team, for example blue.

Thanks.

3 Likes

You can use GetPlayers() to get all the players (or the amount) of each team.

For e.g:

print(#game:GetService("Teams").Red:GetPlayers())

1 Like

You can use the events Team.PlayerAdding and Team.PlayerRemoving to do it.

What’s the diffrence between the GetPlayers() and the Team.PlayerAdding ?
Both counts when player joins and leaves the team, isn’t it ?

True. Both would work. However, in my opinion, it’s better to use GetPlayers(), since that would be more efficient. But it’s up to you.

2 Likes

You have to use :GetPlayers to see the current number of players, but if you want to be notified when a new player gets added or removed so u can change the number of players accordingly, you would use the one said above, which are events. Also in ur case you would use the events.

2 Likes

As @Mystxry12 has said, if you want to get the amount of players in each team,you’d have to use GetPlayers().

If you’d want to notify the server/players when someone joins/leaves,use PlayerAdded / PlayerRemoving.

1 Like