Let's make a fancy live subscriber count in roblox studio

Let’s make a fancy live subscriber count in roblox studio

I can’t provide you with the plugin since roblox have crashed on me for no reason without any warning after I finished the video :frowning: So this plugin only lives on this video currently. If you managed to recreate it, Please share it with me in discord!

This video covers a lot of useful stuff. like how to use HttpService with youtube API. How to handle gui’s and plugin widgets, and more…

I appreciate feedback, constructive criticism and suggestions :smiley:

==== Ressources used ====
Google Cloud Platform (API Key):
https://console.cloud.google.com

NumberSpinner module by @BoatBomber:

I got the inspiration to create this from @iShouldG0 :

6 Likes

Is there any way I could implement this in-game?

1 Like

This will work in-game for sure. Just make sure HttpService is turned on in your game settings.

I there a model I can grab? I’d appreciate that or tell me how to implement it in-game.

1 Like

Unfortunately as I said my studio crashed after an hour of hardwork as you’ve seen in the video. but it’s pretty simple:

First follow my tutorial about how to get your own youtube API key.
Second try to copy the function implementation of GetChannelData(ID) from my video.

GetChannelData will return a table containing the data you need for the specified ID

Alright. Will this work on a surface gui?

1 Like

Yes why not!
It will work everywhere as long as HttpService is on

I managed to recover my live subscriber count plugin :smile:

Install the plugin:
https://www.roblox.com/library/6950187879/Youtube-Subscribers-Tracker
Install the plugin’s model (rbxm):
https://www.roblox.com/library/6950201174/Live-Youtube-Subscriber-Count
Source code:

local HttpService = game:GetService("HttpService")
local NumberSpinner = require(script.NumberSpinner)
 
local Toolbar = plugin:CreateToolbar("Youtube Channel Tracker")
 
local Buttons = {
    ChannelSelector = Toolbar:CreateButton("Select Channel", "Select Channel", ""),
    SubscribersTracker = Toolbar:CreateButton("Subscribers Tracker", "Subscribers Tracker", ""),
}
 
local WidgetInfo = DockWidgetPluginGuiInfo.new(
    Enum.InitialDockState.Left,
    false,
    false,
    400,
    160,
    400,
    160
)
 
local Widgets = {
    ChannelSelector = plugin:CreateDockWidgetPluginGui("ChannelSelector", WidgetInfo),
    SubscribersTracker = plugin:CreateDockWidgetPluginGui("SubscribersTracker", WidgetInfo)
}
 
Widgets.ChannelSelector.Title = "Channel Selector"
Widgets.SubscribersTracker.Title = "Subscribers Tracker"
 
local GUI = script.Parent.GUI
 
local SubcriberCountNumberSpinner = nil
 
local Frames = {
    ChannelSelector = GUI.ChannelSelector,
    SubscribersTracker = GUI.SubscribersTracker
}
 
local SelectButton = Frames.ChannelSelector.Holder.SelectButton
local IDTextBox = Frames.ChannelSelector.Holder.ChannelSelector.TextBox
 
local config = {
    key = "AIzaSyDf4rwNKscEIf5QJ9CQHp7WQlrEzFt6d7I",
    API_URL = "https://www.googleapis.com/youtube/v3/channels?part=statistics&id="
}
 
local open = {
    ChannelSelector = false,
    SubscribersTracker = false
}
 
local function GetChannelData(ID)
    local data = nil
    
    local success, err = pcall(function()
        local url = config.API_URL..ID.."&key="..config.key
        
        local response = HttpService:GetAsync(url)
        data = HttpService:JSONDecode(response)
    end)
    
    if not success then
        warn("Something went wrong!")
    end
    return data.items[1].statistics
end
 
local function UpdateChannelID()
    local ID = IDTextBox.Text
    local ChannelData = GetChannelData(ID)
    if ChannelData.hiddenSubscriberCount then
        warn("The requested channel's subscibers count is hidden!")
    else
        local SubscriberCount = tonumber(ChannelData.subscriberCount)
        SubcriberCountNumberSpinner.Value = SubscriberCount
    end
end
 
local function InitButtons()
    for ButtonName, Button in pairs(Buttons) do
        Button.Click:Connect(function()
            if open[ButtonName] then
                Widgets[ButtonName].Enabled = false
                open[ButtonName] = false
            else
                Widgets[ButtonName].Enabled = true
                open[ButtonName] = true
            end
        end)
    end
end
 
local function InitWidgets()
    for WidgetName, Widget in pairs(Widgets) do
        local frame = Frames[WidgetName]
        frame.Parent = Widget
    end
end
 
local function InitSubscribersTracker()
    SubcriberCountNumberSpinner = NumberSpinner.new()
    SubcriberCountNumberSpinner.Decimals = 0
    SubcriberCountNumberSpinner.Duration = 1
    SubcriberCountNumberSpinner.Parent = Frames.SubscribersTracker.Holder.SubsCount
    SubcriberCountNumberSpinner.Prefix = ""
    SubcriberCountNumberSpinner.Position = UDim2.fromScale(0.5, 0.5)
    SubcriberCountNumberSpinner.AnchorPoint = Vector2.new(0.5, 0.5)
    SubcriberCountNumberSpinner.Size = UDim2.fromScale(1, 1)
    SubcriberCountNumberSpinner.TextSize = 64
end
 
local function Init()
    InitWidgets()
    InitSubscribersTracker()
    InitButtons()
end
 
SelectButton.MouseButton1Click:Connect(UpdateChannelID)
Init()

You should put this in #resources:community-resources

2 Likes

Thanks! I added it to that category!

1 Like

WOW! I’ve been desperately searching for something like this for awhile. Did you use the video I sent you about the YouTube Api?

I know it looks like im going crazy over this but I can’t thank you enough.

2 Likes

Yes mate. It taught me how to get my own API Key through google cloud!

1 Like

Detailed tutorial, alot better than my plugin :wink:

1 Like

How do we put this on a SurfaceGui?

1 Like

You need to be a little bit comfortable with scripting to do so.

Ah okay. I’m totally not comfortable with scripting, as I’m horrible at it. :laughing:

1 Like

I might make a better tutorial for live games.
As this one only covers the plugin way.

1 Like