repeat task.wait() until game:IsLoaded()
pcall(function()
    local PlaceId = game.PlaceId
    local TeleportService = game:GetService("TeleportService")

    local function teleport(id)
        TeleportService:Teleport(id)
    end

    local WindUI = loadstring(game:HttpGet("https://github.com/Footagesus/WindUI/releases/latest/download/main.lua"))()
    WindUI:SetTheme("Dark")

    local Window = WindUI:CreateWindow({
        Title = "Sk1d Hub",
        Icon = "loader",
        Author = "pwngd",
        Size = UDim2.fromOffset(580, 460),
        Transparent = false,
        Image = "",
        Theme = "Dark",
        SideBarWidth = 200,
        Background = "",
        User = {
            Enabled = true,
        },
    })

    local function makeScriptBtn(tab, gameid, callback)
        if PlaceId == gameid then
            if _G.AutoRun then
                Window:Close()
                callback()
                return
            end

            local Button = tab:Button({
                Title = "Run Script",
                Desc = "You're in this game.",
                Locked = false,
                Callback = callback
            })

            WindUI:Popup({
                Title = "Script detected for game",
                Icon = "info",
                Content = "Do you want to run this script?",
                Buttons = {
                    {
                        Title = "Cancel",
                        Callback = function() end,
                        Variant = "Tertiary",
                    },
                    {
                        Title = "Run",
                        Icon = "arrow-right",
                        Callback = callback,
                        Variant = "Primary",
                    }
                }
            })
        else
            local Button = tab:Button({
                Title = "Join Game",
                Desc = "Your not in this game, join it?",
                Locked = false,
                Callback = function()
                    teleport(gameid)
                end
            })
        end
    end

    -------------------- MAIN --------------------
    local main = Window:Tab({
        Title = "Home",
        Icon = "house",
    })

    main:Paragraph({
        Title = "Sk1d Hub",
        Desc = "Script loader for sk1d.org scripts. Choose a game on the sidebar. Join our discord for more!",
    })

    main:Button({
        Title = "Copy Discord Link",
        Desc = "Join our discord!",
        Locked = false,
        Callback = function()
            setclipboard("https://discord.gg/DAKJ5yUpMU")
        end
    })

    Window:SelectTab(1)

    -------------------- TOWN ----------------------
    local town = Window:Tab({
        Title = "Town Script",
        Icon = "gamepad-2"
    })

    town:Section({ 
        Title = "Free, Keyless",
        TextXAlignment = "Left",
        TextSize = 17,
    })

    makeScriptBtn(town, 4991214437, function()
        loadstring(game:HttpGet("https://pandadevelopment.net/virtual/file/e030082f5b81b0a2"))()
    end)

    town:Paragraph({
        Title = "Features",
        Desc = "Silent Aim, ESP, Speedhack, and more. Free script for town.",
    })

    -------------------- DEADZONE --------------------
    local deadzone = Window:Tab({
        Title = "Deadzone Script",
        Icon = "gamepad-2"
    })

    deadzone:Section({ 
        Title = "Free, Key System",
        TextXAlignment = "Left",
        TextSize = 17,
    })

    makeScriptBtn(deadzone, 3221241066, function()
        loadstring(game:HttpGet("https://pandadevelopment.net/virtual/file/5b6562e4c2d7930c"))()
    end)

    deadzone:Paragraph({
        Title = "Disclaimer",
        Desc = "Uses older key system, check discord for more info until this is updated later."
    })
end)