Player.Team and Team:GetPlayers()

I’m here to announce two new additions to the API. They should make working with teams a lot easier. Click on the links for more information.


Returns a list of players which are on this team.


Gets or sets which team the player is on. Returns nil if the player is not on a team.

Bear in mind it will take some time for these changes to be released on all platforms but for now you can use these APIs on the server.


I was not expecting to be able to set the team directly. This is a welcome surprise that will make working with teams a whole lot easier.


Finally no more helper functions to calculate the number of people on a team :+1:


There is a bit of a weird thing that I feel like pointing out. If I have Team1 and Team2 with the same TeamColor (a bit hacky to begin with, but follow along for a second), and I try to set a player’s team as the Team2 object, it will be the Team1 object instead afterwards (or vice versa). You could argue that there shouldn’t be multiple teams with the same TeamColor, but still it’s odd that the object that I set is not the one I read back afterwards. (Should be a note on the wiki, or the entire system could switch to using teams instead of still using teamcolor internally)

Another weird thing in the CoreGui when having multiple teams of the same teamcolor:

Both players have Team1 listed as their team, but the players are displayed under Team2.

Other than that, nice update!


Please avoid having multiple teams with the same TeamColor; it will result in undefined behavior.


Maybe for completeness of the wiki you could stick a short sentence somewhere in there explaining that for new developers (who aren’t familiar with that through experience, especially now that you can abstract from TeamColors and only use Team objects to set/get teams)

1 Like

Noted on the Player.Team page.


These two tiny things alone save so many overall lines of code for me. :heart_eyes:

1 Like

I’ve always wanted this since I started clan stuff.