Game Playercount

Hi, I’m trying to get games player count but I’m not sure how i would get it, I tried using api’s but none worked, anyone knows?

This is for an admin panel.

Maybe this will work, this should give you a variable of the number of players in the game

i = 0
game.Players.PlayersAdded:Connect(function()
    i = i + 1
end)

That would give me number of the players in current server, not all of them

I want to get this:
image

1 Like

Take a look at using the Games Api, and providing the Game/Universe ID. If you plan to do this in-game you need to use a proxy such as rprxy as Roblox does not allow developers to access certain web apis within the game.

You want to get the amount of players in a server, yes? For this, you can simply use:

local playerList = game.Players:GetPlayers()
local int = #playerList

print(int)

This should give you the amount of players currently in the server. If you want it to update when a new player joins, place that inside a loop.

I think you got it wrong, I’m looking to get the playercount of all the servers not the current one so i want to get the playing on roblox’s website

I see. Then I cannot help you there.

I’ve used the api, and the rprxy but it just gives me nil, with games api i get Trust error but its my own place

That’s strange - especially since the Games API for that particular request shouldn’t require any authentication. Do you have any code sample that I could take a look at?

local HttpService = game:GetService("HttpService")

local Data = HttpService:GetAsync("https://games.roblox.com/v1/games?universeIds=2341728123")
print(Data)

Error:

You’re not using a proxy.

Make a request to https://games.rprxy.xyz/v1/games?universeIds=2341728123 instead of https://games.roblox.com/v1/games?universeIds=2341728123

2 Likes

Thanks, do you know how i would get name and stuff for all of that?

What do you mean by name? The name of the players in the server?

It returns

 {"data":[{"id":2341728123,"rootPlaceId":6332310502,"name":"New Leaderboard","description":null,"creator":{"id":217959799,"name":"LovreGFX","type":"User"},"price":null,"allowedGearGenres":["All"],"allowedGearCategories":[],"playing":0,"visits":6,"maxPlayers":50,"created":"2021-02-01T18:10:08.6523052Z","updated":"2021-02-03T00:05:01.0695682Z","studioAccessToApisAllowed":false,"createVipServersAllowed":false,"universeAvatarType":"MorphToR15","genre":"All"}]}

How would i now get stuff from inside

HttpService:JSONDecode(data) would return a lua dictionary with the data

2 Likes

Thank you!! Limit, ty ty limit (chars