local Rayfield = loadstring(game:HttpGet('https://[Log in to view URL]'))()

-- Configurations
local Config = {
    Name = "Rodan Hub | @RodanHub = Youtube",
    Icon = 110387052435330,
    LoadingTitle = "Rodan Hub",
    LoadingSubtitle = "by @RodanHubonYT",
    Theme = "Default",
    DisableRayfieldPrompts = false,
    DisableBuildWarnings = false,
    ConfigFolder = "RodanHub",
    DiscordInvite = "PfazPQfc",
    KeySettings = {
        Title = "Rodan Hub",
        Subtitle = "Key System",
        Note = "Get Key From Verification",
        FileName = "RodanHubKey_" .. game.Players.LocalPlayer.Name,
        SaveKey = true,
        GrabKeyFromSite = true,
        VerificationURL = "https://[Log in to view URL]"
        ApiURL = "https://[Log in to view URL]", -- Your API URL here
        ExpireDays = 3, 
        MaxAttempts = 3 -- Number of attempts to get the key from the API
    }
}

-- Helper function to split a string by delimiter
local function split(str, delimiter)
    local result = {}
    for match in (str..delimiter):gmatch("(.-)"..delimiter) do
        table.insert(result, match)
    end
    return result
end

-- Helper function to fetch the key from the API
local function fetchKeyFromAPI()
    local success, response = pcall(function()
        return game:HttpGet(Config.KeySettings.ApiURL)
    end)
    if success and response then
        return response
    else
        warn("Failed to fetch key from API: " .. tostring(response))
        return nil
    end
end

-- Helper function to save the key locally
local function saveKey(key)
    writefile(Config.KeySettings.FileName, key)
end

-- Helper function to load and check the key
local function loadKey()
    if isfile(Config.KeySettings.FileName) then
        local keyData = readfile(Config.KeySettings.FileName)
        local parts = split(keyData, "|")
        local key = parts[1]
        local timestamp = tonumber(parts[2])
        if os.time() - timestamp < Config.KeySettings.ExpireDays * 86400 then
            return key
        else
            return nil -- Key expired
        end
    else
        return nil -- Key not found
    end
end

-- Helper function to delete the key after expiration
local function deleteKey()
    if isfile(Config.KeySettings.FileName) then
        delfile(Config.KeySettings.FileName)
        print("Key deleted due to expiration.")
    end
end

-- Helper function to prompt the user to get a key from the API
local function promptAPIForKey()
    local attempts = 0
    local key = nil
    while attempts < Config.KeySettings.MaxAttempts do
        print("Attempting to get the key from the API. Attempt " .. (attempts + 1) .. " of " .. Config.KeySettings.MaxAttempts)
        key = fetchKeyFromAPI()
        if key then
            print("Successfully retrieved key from API!")
            return key
        end
        attempts = attempts + 1
        print("Attempt " .. attempts .. " failed. Retrying...")
    end
    return nil
end

-- Load the key or fetch a new one if expired
local currentKey = loadKey()

if not currentKey then
    print("No valid key found. Retrieving key from the API.")
    local newKey = promptAPIForKey()
    if newKey then
        saveKey(newKey .. "|" .. os.time()) -- Save the new key with timestamp
        currentKey = newKey
    else
        error("Failed to retrieve a valid key after multiple attempts.")
    end
else
    -- If the key is expired, delete it and fetch a new one
    local parts = split(readfile(Config.KeySettings.FileName), "|")
    local timestamp = tonumber(parts[2])

    if os.time() - timestamp >= Config.KeySettings.ExpireDays * 86400 then
        print("Your key has expired. Fetching a new one from the API.")
        deleteKey()
        local newKey = promptAPIForKey()
        if newKey then
            saveKey(newKey .. "|" .. os.time()) -- Save the new key with timestamp
            currentKey = newKey
        else
            error("Failed to retrieve a valid key after multiple attempts.")
        end
    end
end

-- Create the Window and Key System
local Window = Rayfield:CreateWindow({
    Name = Config.Name,
    Icon = Config.Icon,
    LoadingTitle = Config.LoadingTitle,
    LoadingSubtitle = Config.LoadingSubtitle,
    Theme = Config.Theme,
    DisableRayfieldPrompts = Config.DisableRayfieldPrompts,
    DisableBuildWarnings = Config.DisableBuildWarnings,
    ConfigurationSaving = {
        Enabled = true,
        FolderName = Config.ConfigFolder,
        FileName = Config.KeySettings.FileName
    },
    Discord = {
        Enabled = true,
        Invite = Config.DiscordInvite,
        RememberJoins = true
    },
    KeySystem = true,
    KeySettings = Config.KeySettings,
    Key = currentKey -- Provide the current key to the KeySystem
})

-- Add Buttons to Tabs
local Tabs = {
    Farm = Window:CreateTab("Farm", 78832038241257),
    Bounty = Window:CreateTab("Bounty", 127881003227995),
    FruitBG = Window:CreateTab("Fruit BG", 75854525981299),
    Fisch = Window:CreateTab("Fisch", 110654365030834),
    Misc = Window:CreateTab("Misc", 108129201671893)
}

-- Button Generator
local function createScriptButton(tab, name, url)
    tab:CreateButton({
        Name = name,
        Callback = function()
            local success, err = pcall(function()
                        

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: