Roblox to Discord webhook for hourly player count

As far as I did is this raw script, but the main question how would it work with 0 players playing your game?

local HttpService = game:GetService("HttpService")
local WebhookURL = "YOUR WEBHOOK URL HERE"

-- Function to send message to Discord using webhook
local function sendMessageToDiscord(message)
    local data = {
        ["content"] = message
    }
    local requestBody = HttpService:JSONEncode(data)
    HttpService:PostAsync(WebhookURL, requestBody)
end

-- Function to get the number of players that have joined the game
local function getNumberOfPlayers()
    return #Players:GetPlayers()
end

-- Send hourly update on the number of players that have joined the game
while true do
    local numberOfPlayers = getNumberOfPlayers()
    local message = "Hourly update: " .. numberOfPlayers .. " players have joined the game."
    sendMessageToDiscord(message)
    wait(3600) -- wait for one hour
end

simply you can’t do anything in a game without a player. no server is run, thus resulting in no server scripts being run.

image

(at least, as far as I know.)

you would have to create an external application/proxy to scrape your Roblox experience’s player count to make it continue with no players.

(would not count each player each hour. to get around this, you could fetch how many visits there have been and subtract the new count from the count an hour ago.)