i dont know a script for this, i just want to print out the number of players playing my game, no i dont mean game.Players:GetPlayers()
i mean the overall amount in all servers, please help,
;-;
local http = game:GetService("HttpService") local gameid = game.GameId --the game id local dat = http:JSONDecode(http:GetAsync("https://games.roblox.com/v1/games?universeIds="..gameid)) print("People playing ", dat[0].playing)
i found a fix thanks to BradNewTypical, i just needed to make the url a proxy.
local http = game:GetService("HttpService") local gameid = game.GameId local body = http:JSONDecode(http:GetAsync("https://games.rprxy.xyz/v1/games?universeIds=".. gameid)) local totalplrs = body.data[1].playing print("Players In Total: ".. totalplrs)
Hi mahid786! We used to do game.Players.NumPlayers
, but that is deprecated now. Instead, try this:
wait() local NumPlayers = game.Players:GetChildren() print(#NumPlayers)
To count all the children of the players, use #NumPlayers
.
An example may be:
if #NumPlayers > 2 then print("There are more than 2 players!") end
This checks if the amount of players are more than 2.
Another example can be:
script.Parent.Text = "There are "..#NumPlayers.. " in the server!"
That changes the text into: "There are " *number of players in the server* "in the server!"
I hope that my examples help you understand! If so, please accept my answer!
New Edit: I got this from the Developer Forum, so if you do not understand this, use this link.
local place_id = 0 --place id there function players_online(place_id) local web = game.HttpService:GetAsync("https://www.rprxy.xyz/games/"..place_id) local player_text = string.find(web,"Playing") -- find the online players section local new = string.sub(web,player_text) local number_start = string.find(new,">") -- find where the number starts new = string.sub(new,number_start) local number_end = string.find(new,"<") -- find where the number ends new = string.sub(new,2,number_end-1) local players_online = string.gsub(new,",","") -- in case it's over 1000 players return tonumber(players_online) end
Again, hope I helped.