RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a server region button that shows how many players are in that game"
-- server script local HttpService = game:GetService("HttpService") local Players = game:GetService("Players") local function getPlayerCount(placeId) local url = "https://games.roblox.com/v1/games/" .. placeId .. "/servers/Public?sortOrder=Asc&limit=10" local response = HttpService:GetAsync(url) local data = HttpService:JSONDecode(response) local totalPlayers = 0 for _, server in ipairs(data.data) do totalPlayers = totalPlayers + server.playing end return totalPlayers end local function onButton1Click() local placeId = 123456789 -- Replace with the Place ID of the server region local playerCount = getPlayerCount(placeId) print("There are currently " .. playerCount .. " players in the game.") end script.Parent.MouseButton1Click:Connect(onButton1Click)