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,
;-;
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.
i understand it, but the thing is i want it so it gets the players in ALL servers not just one.
https://devforum.roblox.com/t/player-count-in-another-place/403105/8 Read this, maybe this is what you mean? https://developer.roblox.com/en-us/api-reference/class/MessagingService
yh thats basically what i wanted thx
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
it says HttpServices are not allowed to access roblox resources
You have to enable HttpServices, Go to Home -> Game Settings - > Options -> Http Requests
still says im not allowed to access roblox resources
Yes, this should be much simpler than my answer. Once you have enabled HttpServices, if it still doesn't work, try to restart roblox studio (Quit, then Reopen)
I just realised: You need to enable http services. To do that, add this line of code: game:GetService("HttpService").HttpEnabled = true