I am trying to make an attribute for the Players service that holds the number of players in game (as NumPlayers was deprecated). If I try to get the attribute, the output prints
Attributes are not currently enabled
. Can anyone help me with this?
✓ ANSWER ACCEPTED
Attributes are not currently enabled?
1 answer
✓ Accepted answer
You don't need to make any big edits on attributes, you can use game.Players:GetPlayers() to get a table of the players on the server, and then you just need to get the size of the table:
local plrs = game.Players:GetPlayers()
print(#plrs) -- this will print the number of players
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
would i have to update the table when a player joins?
yes, you can table.insert() the player or just use :GetPlayers() again