game.Players.PlayerAdded:connect(function() Label = script.Parent.TextLabel Players = game.Players:GetPlayers() Label.Text = "Player Count: "..#Players end) game.Players.PlayerRemoving:connect(function() Label = script.Parent.TextLabel Players = game.Players:GetPlayers() Label.Text = "Player Count: "..#Players end)
Would you use something like messageservice? Not sure how exactly this can count all users in a whole game.
There's an API example at https://devforum.roblox.com/t/how-do-i-get-the-amount-of-players-playing-my-game/541831/8
Code:
--make sure HTTP requests are enabled local HttpService = game:GetService("HttpService") local GameDataJSON = HttpService:GetAsync("https://games.rprxy.com/v1/games?universeIds=" .. game.GameId) local Playing = HttpService:JSONDecode(GameDataJSON).playing