local CountStore = game:GetService("DataStoreService"):GetDataStore("PlayerCount")
local Count = 0
game:GetService("Players").PlayerAdded:Connect(function(Player)
Count = Count + 1
end)
game:GetService("Players").PlayerRemoving:Connect(function(Player)
Count = Count - 1
end)
while wait(30) do
CountStore:UpdateAsync(PlaceId, function(Old)
if Old then
return Old + Count
else
return Count
end
end)
end
I may have missed a few bits but it should get the idea across. It’s also 5AM and I’ve been up for over 48 hours now.
Assuming you want to know how to process the data it’s pretty simple.
The data is stored in a JSON format (but it will return a table with HttpService:JSONDecode)
Here’s accessing the player count of the example:
Eample
local body = game:GetService("HttpService"):JSONDecode(res) --res would be the response from the server
local playerCount = body.data[1].playing
print(playerCount)
Expected Output: 0
(Havent tested, just typed it out here might be some complications…)
res is the response from the server – it’s the result of a GET request. Here’s an example:
local url = "https://games.roblox.com/v1/games?universeIds={UniverseIDs}"
local res = game:GetService("HttpService"):GetAsync(URL)
-- Then paste the other code
This obviously won’t work because:
You need the universe ID
You need to proxy the request since Roblox does not allow you to use Roblox’s web apis from the game server.
technically no, all that needs changing is the URL and pasting the rest of the code
but you need to 1 past the ID of the universe (NOT THE PLACE ID) and then proxy it (you can do it yourself – there are many tutorials in #resources for it).