Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

How do I implement a system that shows the difference in subscribers?

$
0
0

I was playing around with Roblox's HTTP request system and YouTube's API, and I made a working system that displays your current subscriber count. But I've been trying for a long time and failing to make a system that displays the difference in subscribers in the console.

Is there any way I can implement this in my code?

local HttpService = game:GetService("HttpService")local API_KEY = "SECRET" -- Replace with your API keylocal CHANNEL_ID = "UCA4yZCVHlHZVknfesTU3XOg" -- Replace with your channel IDlocal fonts = {        Enum.Font.Arcade,        Enum.Font.Arial,        Enum.Font.ArialBold,        Enum.Font.Bangers,        Enum.Font.Bodoni,        Enum.Font.Cartoon,        Enum.Font.Code,        Enum.Font.Creepster,        Enum.Font.DenkOne,        Enum.Font.Fantasy,        Enum.Font.Fondamento,        Enum.Font.FredokaOne,        Enum.Font.Garamond,        Enum.Font.Gotham,        Enum.Font.GothamBlack,    }local function getChannelStats()    print("SENDING REQUEST")    local success, result = pcall(function()        local url = string.format("https://www.googleapis.com/youtube/v3/channels?part=statistics&id=%s&key=%s", CHANNEL_ID, API_KEY)        local response = HttpService:GetAsync(url)        local data = HttpService:JSONDecode(response)        local subscriberCount = data.items[1].statistics.subscriberCount        --script.Parent.Text = "Inscritos: " .. subscriberCount        script.Parent.Text = subscriberCount        script.Parent.Font = fonts[math.random(1, #fonts)]    end)    if not success then        warn("Error fetching channel data:", result)        --script.Parent.Text = "Erro ao carregar dados."    endend-- Call the function initially and every 10 secondsgetChannelStats()while true do    wait(2)    getChannelStats()end

I tried doing it myself, using Roblox's AI, testing some things/code snippets, but nothing worked. The expectation was to display the difference in subscribers in the Roblox console using print()


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>