Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is there a way to make this script where it counts all players in EVERY server?

Asked by
DYBB 8
4 years ago
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.

1 answer

Log in to vote
1
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago

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
Ad

Answer this question