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

How to Use PlaceID to find Total Number of Players?

Asked by 6 years ago

So, I don't really have much besides some code that I tried to find, but I'm trying to find the total number of players in the game using the PlaceID..

I don't know what to use, besides these codes.

local gameid = 970631874

local NumPlayers = #game.Players:GetPlayers();

For the #game, how would I correlate that to the gameID instead of the server game?

My explanation is really bad, but I have a lobby. And from there, I'm going to have 4 different teleporters that will teleport to different places. I was wondering if I could get the total amount of people playing that exact game.

-- inside the brick where it finds all the players

while true do
wait(0.2)
if game.Players.NumPlayers == 1 then --instead of the server that it is in, how to make it a specific PlaceID?
script.Parent.Text = "There is " ..game.Players.NumPlayers.. " player online"
else
script.Parent.Text = "There are " ..game.Players.NumPlayers.. " players online"
end
end

-- serverside

game.Player.PlayerAdded:connect(function()
game:GetService("DataStoreService"):GetDataStore("Plrs"):IncrementAsync("Players",1)
end)

game.Player.PlayerRemoving:connect(function()
game:GetService("DataStoreService"):GetDataStore("Plrs"):IncrementAsync("Players",-1)
end)

Hopefully these codes will help to make a solution.

Thanks,

LukeGabrieI aka EnergyBrickz

0
Why cant you just write it into there? You're the game developer, so you should know. hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

I'm pretty sure this isn't in ROBLOX's API. You'd need to use HTTP service and scrape the page with your place id, parse the page, find the div that shows the players playing (if that even shows on attached games), then return the number. If anyone has another idea, I'll delete this~

0
The only other way would be to use http service/Data stores to keep track of the number of players (when they enter and leave) instead of getting the number shown on the roblox game. Either way it's probably not worth it iamnoamesa 674 — 6y
0
You cannot access Roblox with HTTP service, without making your own website to call Roblox. hiimgoodpack 2009 — 6y
0
Welp it was more complicated than I thought lol LukeGabrieI 73 — 6y
0
@iamnoamesa Thought about that, would not be worth it like you said. @hiimgoodpack - indeed. Azarth 3141 — 6y
Ad

Answer this question