Akena Hub Leaked SRC
Key Required

Akena Hub Leaked SRC

Football Fusion 3ScriptLeakDCJeffyrrScriptLeakDCJeffyrr 1.5K views 23.2K executesUpdated Aug 9, 2026
Unrated
00
Lua Script•6622 lines (242117 chars)
local UserInputService = game:GetService('UserInputService')
local TweenService = game:GetService('TweenService')
local RunService = game:GetService('RunService')
local CoreGui = game:GetService('CoreGui')
local Players = game:GetService('Players')
local TextService = game:GetService('TextService')
local HttpService = game:GetService('HttpService')

local LocalPlayer = Players.LocalPlayer
local uiParent = (pcall(function() return CoreGui.Name end) and CoreGui) or LocalPlayer:WaitForChild('PlayerGui')

local Themes = {
    ['Default'] = {
        MainBG = Color3.fromRGB(15, 15, 17),
        SidebarBG = Color3.fromRGB(18, 18, 21),
        TopbarBG = Color3.fromRGB(12, 12, 14),
        ElementBG = Color3.fromRGB(24, 24, 27),
        Accent = Color3.fromRGB(59, 130, 246),
        TextMain = Color3.fromRGB(240, 240, 240),
        TextSub = Color3.fromRGB(160, 160, 165),
        Border = Color3.fromRGB(39, 39, 42),
        DropdownListBG = Color3.fromRGB(24, 24, 27),
        DropdownListStroke = Color3.fromRGB(39, 39, 42)
    },
    ['Dracula'] = {
        MainBG = Color3.fromRGB(40, 42, 54),
        SidebarBG = Color3.fromRGB(33, 34, 44),
        TopbarBG = Color3.fromRGB(24, 25, 33),
        ElementBG = Color3.fromRGB(56, 58, 89),
        Accent = Color3.fromRGB(189, 147, 249),
        TextMain = Color3.fromRGB(248, 248, 242),
        TextSub = Color3.fromRGB(160, 165, 180),
        Border = Color3.fromRGB(68, 71, 90),
        DropdownListBG = Color3.fromRGB(56, 58, 89),
        DropdownListStroke = Color3.fromRGB(68, 71, 90)
    },
    ['Tokyo Night'] = {
        MainBG = Color3.fromRGB(26, 27, 38),
        SidebarBG = Color3.fromRGB(31, 35, 53),
        TopbarBG = Color3.fromRGB(22, 22, 30),
        ElementBG = Color3.fromRGB(41, 46, 66),
        Accent = Color3.fromRGB(122, 162, 247),
        TextMain = Color3.fromRGB(192, 202, 245),
        TextSub = Color3.fromRGB(120, 124, 153),
        Border = Color3.fromRGB(56, 62, 86),
        DropdownListBG = Color3.fromRGB(41, 46, 66),
        DropdownListStroke = Color3.fromRGB(56, 62, 86)
    },
    ['Catppuccin'] = {
        MainBG = Color3.fromRGB(30, 30, 46),
        SidebarBG = Color3.fromRGB(24, 24, 37),
        TopbarBG = Color3.fromRGB(17, 17, 27),
        ElementBG = Color3.fromRGB(49, 50, 68),
        Accent = Color3.fromRGB(203, 166, 247),
        TextMain = Color3.fromRGB(205, 214, 244),
        TextSub = Color3.fromRGB(166, 173, 200),
        Border = Color3.fromRGB(69, 71, 90),
        DropdownListBG = Color3.fromRGB(49, 50, 68),
        DropdownListStroke = Color3.fromRGB(69, 71, 90)
    },
    ['Rose Pine'] = {
        MainBG = Color3.fromRGB(25, 23, 36),
        SidebarBG = Color3.fromRGB(31, 29, 46),
        TopbarBG = Color3.fromRGB(20, 18, 28),
        ElementBG = Color3.fromRGB(38, 35, 58),
        Accent = Color3.fromRGB(235, 188, 186),
        TextMain = Color3.fromRGB(224, 222, 244),
        TextSub = Color3.fromRGB(144, 140, 170),
        Border = Color3.fromRGB(49, 47, 68),
        DropdownListBG = Color3.fromRGB(38, 35, 58),
        DropdownListStroke = Color3.fromRGB(49, 47, 68)
    },
    ['Minimal White'] = {
        MainBG = Color3.fromRGB(15, 15, 15),
        SidebarBG = Color3.fromRGB(20, 20, 20),
        TopbarBG = Color3.fromRGB(10, 10, 10),
        ElementBG = Color3.fromRGB(26, 26, 26),
        Accent = Color3.fromRGB(255, 255, 255),
        TextMain = Color3.fromRGB(255, 255, 255),
        TextSub = Color3.fromRGB(170, 170, 170),
        Border = Color3.fromRGB(40, 40, 40),
        DropdownListBG = Color3.fromRGB(26, 26, 26),
        DropdownListStroke = Color3.fromRGB(40, 40, 40)
    }
}

local Theme = {}
for k, v in pairs(Themes['Minimal White']) do Theme[k] = v end

local AkenaLib = {}
AkenaLib.Flags = {}
AkenaLib.ThemeConnections = {}
AkenaLib.RainbowAccent = false
AkenaLib.RainbowSpeed = 5
AkenaLib.ShowNotifications = true
AkenaLib.ShowTooltips = true

local SetupDirectories = function()
    if delfolder and makefolder and isfolder then
        if isfolder('cheeto') then
            pcall(delfolder, 'cheeto')
        end
        if isfolder('akena') then
            if isfile and not isfile('akena/v2_marker.txt') then
                pcall(delfolder, 'akena')
                pcall(makefolder, 'akena')
                if writefile then
                    pcall(writefile, 'akena/v2_marker.txt', 'v2')
                end
            end
        else
            pcall(makefolder, 'akena')
            if writefile then
                pcall(writefile, 'akena/v2_marker.txt', 'v2')
            end
        end
    end
end
SetupDirectories()

local createInstance = function(className, properties)
    local inst = Instance.new(className)
    for k, v in pairs(properties or {}) do
        inst[k] = v
    end
    return inst
end

local getStringValue = function(val)
    if type(val) == 'table' then
        if val.Type == 'Color3' then
            return string.format('RGB: %d, %d, %d', math.floor(val.R * 255), math.floor(val.G * 255), math.floor(val.B * 255))
        elseif val.Type == 'EnumItem' then
            return tostring(val.Name)
        end
        for _, v in pairs(val) do
            if type(v) == 'string' or type(v) == 'number' then
                return tostring(v)
            end
        end
        return 'None'
    end
    return val ~= nil and tostring(val) or 'None'
end

local regTheme = function(instance, callback)
    table.insert(AkenaLib.ThemeConnections, function()
        local success, hasParent = pcall(function() return instance and instance.Parent end)
        if success and hasParent then
            callback()
            return true
        end
        return false
    end)
    callback()
end

local UpdateThemeAccent = function(newColor)
    Theme.Accent = newColor
    local alive = {}
    for i = 1, #AkenaLib.ThemeConnections do
        local func = AkenaLib.ThemeConnections[i]
        if type(func) == 'function' then
            local s, res = pcall(func)
            if s and res ~= false then 
                table.insert(alive, func) 
            end
        end
    end
    AkenaLib.ThemeConnections = alive
end

local ApplySelectedTheme = function(themeName)
    local targetTheme = Themes[themeName]
    if not targetTheme then return end
    for k, v in pairs(targetTheme) do
        Theme[k] = v
    end
    local alive = {}
    for i = 1, #AkenaLib.ThemeConnections do
        local func = AkenaLib.ThemeConnections[i]
        if type(func) == 'function' then
            local s, res = pcall(func)
            if s and res ~= false then 
                table.insert(alive, func) 
            end
        end
    end
    AkenaLib.ThemeConnections = alive
end

RunService.RenderStepped:Connect(function()
    if AkenaLib.RainbowAccent then
        local hue = tick() * (AkenaLib.RainbowSpeed / 100) % 1
        UpdateThemeAccent(Color3.fromHSV(hue, 1, 1))
    end
end)

local GetDarkerColor = function(color, factor)
    local h, s, v = Color3.toHSV(color)
    return Color3.fromHSV(h, s, math.clamp(v * factor, 0, 1))
end

local SerializeValue = function(val)
    if typeof(val) == 'Color3' then
        return {Type = 'Color3', R = val.R, G = val.G, B = val.B}
    elseif typeof(val) == 'EnumItem' then
        return {Type = 'EnumItem', EnumType = tostring(val.EnumType), Name = val.Name}
    elseif typeof(val) == 'table' then
        local tbl = {}
        for k, v in pairs(val) do
            tbl[k] = SerializeValue(v)
        end
        return tbl
    end
    return val
end

local DeserializeValue = function(val)
    if type(val) == 'table' then
        if val.Type == 'Color3' then
            return Color3.new(val.R, val.G, val.B)
        elseif val.Type == 'EnumItem' then
            local success, enum = pcall(function() return Enum[val.EnumType][val.Name] end)
            return success and enum or nil
        else
            local tbl = {}
            for k, v in pairs(val) do
                tbl[k] = DeserializeValue(v)
            end
            return tbl
        end
    end
    return val
end

AkenaLib.Notify = function(self, options)
    if not AkenaLib.ShowNotifications then return end
    local Title = options.Title or 'Notification'
    local Content = options.Content or 'Notification content goes here.'
    local Duration = options.Duration or 3

    local ScreenGui = uiParent:FindFirstChild('AkenaUI')
    if not ScreenGui then return end
    
    local NotifContainer = ScreenGui:FindFirstChild('NotifyContainer')
    if not NotifContainer then return end

    local Wrapper = createInstance('Frame', {
        Parent = NotifContainer,
        BackgroundTransparency = 1,
        Size = UDim2.new(0, 260, 0, 0),
        ClipsDescendants = true,
        ZIndex = 200
    })

    local NotifCard = createInstance('CanvasGroup', {
        Parent = Wrapper,
        BackgroundColor3 = Theme.MainBG,
        BackgroundTransparency = 0.35,
        Size = UDim2.new(1, 0, 0, 75),
        Position = UDim2.new(1, 300, 0, 0),
        GroupTransparency = 1,
        ZIndex = 200
    })
    createInstance('UICorner', {Parent = NotifCard, CornerRadius = UDim.new(0, 6)})
    regTheme(NotifCard, function() NotifCard.BackgroundColor3 = Theme.MainBG end)

    local TitleLbl = createInstance('TextLabel', {
        Parent = NotifCard,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 0, 0, 10),
        Size = UDim2.new(1, 0, 0, 16),
        Font = Enum.Font.GothamBold,
        Text = Title,
        TextColor3 = Theme.Accent,
        TextSize = 14,
        TextXAlignment = Enum.TextXAlignment.Center,
        ZIndex = 201
    })
    regTheme(TitleLbl, function() TitleLbl.TextColor3 = Theme.Accent end)

    local InfoLbl = createInstance('TextLabel', {
        Parent = NotifCard,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 15, 0, 30),
        Size = UDim2.new(1, -30, 0, 35),
        Font = Enum.Font.Gotham,
        Text = Content,
        TextColor3 = Theme.TextSub,
        TextSize = 12,
        TextXAlignment = Enum.TextXAlignment.Center,
        TextWrapped = true,
        ZIndex = 201
    })
    regTheme(InfoLbl, function() InfoLbl.TextColor3 = Theme.TextSub end)

    local LineFrame = createInstance('Frame', {
        Parent = NotifCard,
        BackgroundColor3 = Theme.Accent,
        BorderSizePixel = 0,
        AnchorPoint = Vector2.new(0.5, 1),
        Position = UDim2.new(0.5, 0, 1, 0),
        Size = UDim2.new(1, 0, 0, 2),
        ZIndex = 201
    })
    createInstance('UICorner', {Parent = LineFrame, CornerRadius = UDim.new(1, 0)})
    regTheme(LineFrame, function() LineFrame.BackgroundColor3 = Theme.Accent end)

    TweenService:Create(Wrapper, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Size = UDim2.new(0, 260, 0, 85)}):Play()
    TweenService:Create(NotifCard, TweenInfo.new(0.4, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {
        Position = UDim2.new(0, 0, 0, 0),
        GroupTransparency = 0
    }):Play()
    TweenService:Create(LineFrame, TweenInfo.new(Duration, Enum.EasingStyle.Linear), {Size = UDim2.new(0, 0, 0, 2)}):Play()

    task.delay(Duration, function()
        local outTween = TweenService:Create(NotifCard, TweenInfo.new(0.4, Enum.EasingStyle.Quart, Enum.EasingDirection.In), {
            Position = UDim2.new(1, 300, 0, 0),
            GroupTransparency = 1
        })
        outTween:Play()
        outTween.Completed:Wait()
        TweenService:Create(Wrapper, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.In), {Size = UDim2.new(0, 260, 0, 0)}):Play()
        task.delay(0.3, function() Wrapper:Destroy() end)
    end)
end

AkenaLib.CreateWindow = function(self, options)
    local WindowTitle = options.Title or 'na'
    local TitlePrefix = options.Prefix or 'Ake'
    local defaultTheme = options.Theme or 'Minimal White'
    
    local ScreenGui = createInstance('ScreenGui', {
        Name = 'AkenaUI',
        ResetOnSpawn = false,
        ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
        Parent = uiParent
    })
    
    if uiParent:FindFirstChild('AkenaUI') and uiParent:FindFirstChild('AkenaUI') ~= ScreenGui then
        uiParent:FindFirstChild('AkenaUI'):Destroy()
    end

    local isMobile = UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled

    local MainGroup = createInstance('CanvasGroup', {
        Name = 'MainGroup',
        Parent = ScreenGui,
        BackgroundColor3 = Theme.MainBG,
        AnchorPoint = Vector2.new(0.5, 0.5),
        Position = UDim2.new(0.5, 0, 0.5, 0),
        Size = UDim2.new(0, 580, 0, 360),
        BorderSizePixel = 0
    })
    regTheme(MainGroup, function() MainGroup.BackgroundColor3 = Theme.MainBG end)
    
    local CurrentScale = 1
    local MainScale = createInstance('UIScale', {Parent = MainGroup, Scale = CurrentScale})
    local ScalesToUpdate = {MainScale}

    local WindowObj = { Tabs = {}, CurrentTab = nil, ElementsList = {} }
    
    local MenuVisible = true
    
    local UpdateScale = function(newScale)
        CurrentScale = newScale
        if MenuVisible then
            for i = 1, #ScalesToUpdate do
                local scaleObj = ScalesToUpdate[i]
                TweenService:Create(scaleObj, TweenInfo.new(0.2, Enum.EasingStyle.Quad), {Scale = CurrentScale}):Play()
            end
        end
    end
    
    WindowObj.UpdateScale = function(self, newScale)
        local scale = type(self) == 'number' and self or newScale
        UpdateScale(scale)
    end

    createInstance('UICorner', {Parent = MainGroup, CornerRadius = UDim.new(0, 6)})

    local MainStrokeFrame = createInstance('Frame', {
        Name = 'StrokeFrame',
        Parent = MainGroup,
        BackgroundTransparency = 1,
        Size = UDim2.new(1, 0, 1, 0)
    })
    createInstance('UICorner', {Parent = MainStrokeFrame, CornerRadius = UDim.new(0, 6)})
    local MainStroke = createInstance('UIStroke', {Parent = MainStrokeFrame, Color = Theme.Border})
    regTheme(MainStroke, function() MainStroke.Color = Theme.Border end)

    local NotifyContainer = createInstance('Frame', {
        Name = 'NotifyContainer',
        Parent = ScreenGui,
        BackgroundTransparency = 1,
        AnchorPoint = Vector2.new(1, 1),
        Position = UDim2.new(1, -20, 1, -20),
        Size = UDim2.new(0, 300, 1, 0),
        ZIndex = 100
    })

    createInstance('UIListLayout', {
        Parent = NotifyContainer,
        SortOrder = Enum.SortOrder.LayoutOrder,
        VerticalAlignment = Enum.VerticalAlignment.Bottom,
        HorizontalAlignment = Enum.HorizontalAlignment.Right,
        Padding = UDim.new(0, 10)
    })

    local TooltipCard = createInstance('CanvasGroup', {
        Name = 'TooltipCard',
        Parent = ScreenGui,
        BackgroundColor3 = Theme.MainBG,
        BackgroundTransparency = 0.1,
        Size = UDim2.new(0, 0, 0, 24),
        Position = UDim2.new(0, 0, 0, 0),
        BorderSizePixel = 0,
        Visible = false,
        GroupTransparency = 1,
        ZIndex = 300
    })
    regTheme(TooltipCard, function() TooltipCard.BackgroundColor3 = Theme.MainBG end)
    createInstance('UICorner', {Parent = TooltipCard, CornerRadius = UDim.new(0, 2)})
    createInstance('UIPadding', {Parent = TooltipCard, PaddingLeft = UDim.new(0, 10), PaddingRight = UDim.new(0, 10)})
    
    local TooltipLine = createInstance('Frame', {
        Parent = TooltipCard,
        BackgroundColor3 = Theme.Accent,
        BorderSizePixel = 0,
        Position = UDim2.new(0, -10, 0, 0),
        Size = UDim2.new(0, 3, 1, 0),
        ZIndex = 301
    })
    regTheme(TooltipLine, function() TooltipLine.BackgroundColor3 = Theme.Accent end)
    
    local TooltipText = createInstance('TextLabel', {
        Parent = TooltipCard,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 0, 0, 0),
        Size = UDim2.new(0, 0, 1, 0),
        Font = Enum.Font.GothamMedium,
        Text = '',
        TextColor3 = Theme.TextMain,
        TextSize = 11,
        TextXAlignment = Enum.TextXAlignment.Left,
        AutomaticSize = Enum.AutomaticSize.X,
        ZIndex = 301
    })
    regTheme(TooltipText, function() TooltipText.TextColor3 = Theme.TextMain end)

    local tooltipActive = false
    local activeHoveredElement = nil
    local tooltipCurrentOffset = 20
    local targetTooltipOffset = 20

    local ShowTooltip = function(text, targetY)
        if not AkenaLib.ShowTooltips then return end
        if not text or text == '' then return end
        TooltipText.Text = text
        TooltipCard.AutomaticSize = Enum.AutomaticSize.X
        TooltipCard.Visible = true
        tooltipActive = true
        targetTooltipOffset = 0
        
        TweenService:Create(TooltipCard, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {
            GroupTransparency = 0
        }):Play()
    end
    
    local HideTooltip = function()
        tooltipActive = false
        targetTooltipOffset = 20
        TweenService:Create(TooltipCard, TweenInfo.new(0.2, Enum.EasingStyle.Quart, Enum.EasingDirection.In), {
            GroupTransparency = 1
        }):Play()
        task.delay(0.2, function() 
            if not tooltipActive then
                TooltipCard.Visible = false
            end
        end)
    end

    RunService.RenderStepped:Connect(function(dt)
        if TooltipCard.Visible and activeHoveredElement then
            tooltipCurrentOffset = tooltipCurrentOffset + (targetTooltipOffset - tooltipCurrentOffset) * math.clamp(dt * 15, 0, 1)
            local targetY = activeHoveredElement.AbsolutePosition.Y + (activeHoveredElement.AbsoluteSize.Y / 2) - (TooltipCard.AbsoluteSize.Y / 2)
            local mainX = MainGroup.AbsolutePosition.X + MainGroup.AbsoluteSize.X + 15 + tooltipCurrentOffset
            TooltipCard.Position = UDim2.new(0, mainX, 0, targetY)
        end
    end)

    local SetupTooltip = function(elementFrame, tipText)
        if not tipText or tipText == '' then return end
        elementFrame.MouseEnter:Connect(function()
            activeHoveredElement = elementFrame
            ShowTooltip(tipText, elementFrame.AbsolutePosition.Y)
        end)
        elementFrame.MouseLeave:Connect(function()
            if activeHoveredElement == elementFrame then
                activeHoveredElement = nil
                HideTooltip()
            end
        end)
    end

    local MenuKeybind = Enum.KeyCode.RightControl

    local ToggleMenuVisible = function(state)
        if state ~= nil then MenuVisible = state else MenuVisible = not MenuVisible end
        MainGroup.Interactable = MenuVisible
        
        if MenuVisible then
            MainGroup.Visible = true
            TweenService:Create(MainGroup, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {GroupTransparency = 0}):Play()
            TweenService:Create(MainStroke, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Transparency = 0}):Play()
            for i = 1, #ScalesToUpdate do
                local scaleObj = ScalesToUpdate[i]
                TweenService:Create(scaleObj, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Scale = CurrentScale}):Play()
            end
        else
            TweenService:Create(MainGroup, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {GroupTransparency = 1}):Play()
            TweenService:Create(MainStroke, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Transparency = 1}):Play()
            for i = 1, #ScalesToUpdate do
                local scaleObj = ScalesToUpdate[i]
                TweenService:Create(scaleObj, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Scale = CurrentScale * 0.95}):Play()
            end
            task.delay(0.3, function() if not MenuVisible then MainGroup.Visible = false end end)
        end
    end

    UserInputService.InputBegan:Connect(function(input, gpe)
        if not gpe and input.KeyCode == MenuKeybind then ToggleMenuVisible() end
    end)

    if isMobile then
        local ToggleBtn = createInstance('ImageButton', {
            Parent = ScreenGui,
            BackgroundColor3 = Theme.MainBG,
            AnchorPoint = Vector2.new(0.5, 0),
            Position = UDim2.new(0.5, 0, 0, 20),
            Size = UDim2.new(0, 48, 0, 40),
            AutoButtonColor = false,
            Image = ''
        })
        createInstance('UICorner', {Parent = ToggleBtn, CornerRadius = UDim.new(0, 8)})
        local btnStroke = createInstance('UIStroke', {Parent = ToggleBtn, Color = Theme.Border, ApplyStrokeMode = Enum.ApplyStrokeMode.Border})
        regTheme(ToggleBtn, function() 
            ToggleBtn.BackgroundColor3 = Theme.MainBG
            btnStroke.Color = Theme.Border
        end)

        local TogTextFrame = createInstance('Frame', {
            Parent = ToggleBtn,
            BackgroundTransparency = 1,
            Size = UDim2.new(1, 0, 1, 0)
        })

        local TogText = createInstance('TextLabel', {
            Parent = TogTextFrame,
            BackgroundTransparency = 1,
            Size = UDim2.new(1, 0, 1, 0),
            RichText = true,
            Font = Enum.Font.GothamBold,
            TextColor3 = Color3.fromRGB(255, 255, 255),
            TextSize = 14,
            Text = '<i>AKE</i>'
        })
        regTheme(TogText, function() TogText.TextColor3 = Theme.TextMain end)

        local draggingTog, dragInputTog, dragStartTog, startPosTog
        ToggleBtn.InputBegan:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
                draggingTog = true
                dragStartTog = input.Position
                startPosTog = ToggleBtn.Position
            end
        end)
        ToggleBtn.InputChanged:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseMovement then
                dragInputTog = input
            end
        end)
        UserInputService.InputChanged:Connect(function(input)
            if input == dragInputTog and draggingTog then
                local delta = input.Position - dragStartTog
                ToggleBtn.Position = UDim2.new(startPosTog.X.Scale, startPosTog.X.Offset + delta.X, startPosTog.Y.Scale, startPosTog.Y.Offset + delta.Y)
            end
        end)
        UserInputService.InputEnded:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
                draggingTog = false
            end
        end)
        ToggleBtn.MouseButton1Click:Connect(function() ToggleMenuVisible() end)
    end

    local Topbar = createInstance('Frame', {
        Name = 'Topbar',
        Parent = MainGroup,
        BackgroundColor3 = Theme.TopbarBG,
        Size = UDim2.new(1, 0, 0, 48),
        BorderSizePixel = 0,
        ZIndex = 2
    })
    regTheme(Topbar, function() Topbar.BackgroundColor3 = Theme.TopbarBG end)

    local TopbarBorder = createInstance('Frame', {
        Parent = Topbar,
        BackgroundColor3 = Theme.Border,
        BorderSizePixel = 0,
        Position = UDim2.new(0, 0, 1, -1),
        Size = UDim2.new(1, 0, 0, 1)
    })
    regTheme(TopbarBorder, function() TopbarBorder.BackgroundColor3 = Theme.Border end)

    local dragging, dragInput, dragStart, startPos
    Topbar.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragging = true
            dragStart = input.Position
            startPos = MainGroup.Position
            input.Changed:Connect(function()
                if input.UserInputState == Enum.UserInputState.End then dragging = false end
            end)
        end
    end)
    Topbar.InputChanged:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
            dragInput = input
        end
    end)
    UserInputService.InputChanged:Connect(function(input)
        if input == dragInput and dragging then
            local delta = input.Position - dragStart
            TweenService:Create(MainGroup, TweenInfo.new(0.1, Enum.EasingStyle.Linear), {
                Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
            }):Play()
        end
    end)

    local cleanTitle = TitlePrefix .. WindowTitle
    local titleBounds = TextService:GetTextSize(cleanTitle, 22, Enum.Font.GothamBold, Vector2.new(1000, 48))

    local TitleLabel = createInstance('TextLabel', {
        Parent = Topbar,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 18, 0, 0),
        Size = UDim2.new(0, titleBounds.X + 10, 1, 0),
        Font = Enum.Font.GothamBold,
        Text = string.format('<i>%s</i>%s', TitlePrefix, WindowTitle),
        RichText = true,
        TextColor3 = Theme.TextMain,
        TextSize = 22,
        TextXAlignment = Enum.TextXAlignment.Left
    })
    regTheme(TitleLabel, function() TitleLabel.TextColor3 = Theme.TextMain end)

    local profileText = 'Welcome, ' .. LocalPlayer.Name
    local profileBounds = TextService:GetTextSize(profileText, 12, Enum.Font.Gotham, Vector2.new(1000, 48))

    local ProfileBox = createInstance('Frame', {
        Parent = Topbar,
        BackgroundColor3 = Theme.MainBG,
        AnchorPoint = Vector2.new(1, 0.5),
        Position = UDim2.new(1, -50, 0.5, 0),
        Size = UDim2.new(0, profileBounds.X + 42, 0, 30)
    })
    createInstance('UICorner', {Parent = ProfileBox, CornerRadius = UDim.new(0, 4)})
    local ProfileStroke = createInstance('UIStroke', {Parent = ProfileBox, Color = Theme.Border})
    regTheme(ProfileBox, function() 
        ProfileBox.BackgroundColor3 = Theme.MainBG
        ProfileStroke.Color = Theme.Border
    end)

    local AvatarImg = createInstance('ImageLabel', {
        Parent = ProfileBox,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 4, 0.5, -11),
        Size = UDim2.new(0, 22, 0, 22)
    })
    createInstance('UICorner', {Parent = AvatarImg, CornerRadius = UDim.new(1, 0)})

    task.spawn(function()
        local content, isReady = Players:GetUserThumbnailAsync(LocalPlayer.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size48x48)
        if isReady then AvatarImg.Image = content end
    end)

    local ProfileName = createInstance('TextLabel', {
        Parent = ProfileBox,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 32, 0, 0),
        Size = UDim2.new(1, -36, 1, 0),
        Font = Enum.Font.Gotham,
        Text = profileText,
        TextColor3 = Theme.TextMain,
        TextSize = 12,
        TextXAlignment = Enum.TextXAlignment.Left
    })
    regTheme(ProfileName, function() ProfileName.TextColor3 = Theme.TextMain end)

    local SearchOverlay = createInstance('CanvasGroup', {
        Parent = ScreenGui,
        BackgroundColor3 = Color3.fromRGB(0, 0, 0),
        BackgroundTransparency = 0.5,
        Size = UDim2.new(1, 0, 1, 0),
        ZIndex = 500,
        GroupTransparency = 1,
        Visible = false
    })

    local SearchPanel = createInstance('Frame', {
        Parent = SearchOverlay,
        BackgroundColor3 = Theme.MainBG,
        AnchorPoint = Vector2.new(0.5, 0.5),
        Position = UDim2.new(0.5, 0, 0.5, -20),
        Size = UDim2.new(0, 400, 0, 300),
        ClipsDescendants = true
    })
    createInstance('UICorner', {Parent = SearchPanel, CornerRadius = UDim.new(0, 6)})
    local SearchPanelStroke = createInstance('UIStroke', {Parent = SearchPanel, Color = Theme.Border})
    regTheme(SearchPanel, function() 
        SearchPanel.BackgroundColor3 = Theme.MainBG
        SearchPanelStroke.Color = Theme.Border 
    end)

    local SearchInputBox = createInstance('TextBox', {
        Parent = SearchPanel,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 20, 0, 10),
        Size = UDim2.new(1, -40, 0, 40),
        Font = Enum.Font.GothamMedium,
        PlaceholderText = 'Search elements...',
        PlaceholderColor3 = Theme.TextSub,
        TextColor3 = Theme.TextMain,
        TextSize = 14,
        TextXAlignment = Enum.TextXAlignment.Left,
        ClearTextOnFocus = false,
        Text = ''
    })
    regTheme(SearchInputBox, function() 
        SearchInputBox.TextColor3 = Theme.TextMain 
        SearchInputBox.PlaceholderColor3 = Theme.TextSub
    end)
    
    local SearchLine = createInstance('Frame', {
        Parent = SearchPanel,
        BackgroundColor3 = Theme.Border,
        BorderSizePixel = 0,
        Position = UDim2.new(0, 0, 0, 55),
        Size = UDim2.new(1, 0, 0, 1)
    })
    regTheme(SearchLine, function() SearchLine.BackgroundColor3 = Theme.Border end)

    local SearchScroll = createInstance('ScrollingFrame', {
        Parent = SearchPanel,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 10, 0, 65),
        Size = UDim2.new(1, -20, 1, -75),
        ScrollBarThickness = 2,
        ScrollBarImageColor3 = Theme.Border,
        BorderSizePixel = 0,
        AutomaticCanvasSize = Enum.AutomaticSize.Y,
        CanvasSize = UDim2.new(0, 0, 0, 0)
    })
    regTheme(SearchScroll, function() SearchScroll.ScrollBarImageColor3 = Theme.Border end)

    createInstance('UIListLayout', {
        Parent = SearchScroll,
        SortOrder = Enum.SortOrder.LayoutOrder,
        Padding = UDim.new(0, 5)
    })

    local SearchBtn = createInstance('ImageButton', {
        Parent = Topbar,
        BackgroundTransparency = 1,
        AnchorPoint = Vector2.new(1, 0.5),
        Position = UDim2.new(1, -15, 0.5, 0),
        Size = UDim2.new(0, 24, 0, 24),
        Image = 'rbxassetid://6031154871',
        ImageColor3 = Theme.TextSub
    })
    regTheme(SearchBtn, function() SearchBtn.ImageColor3 = Theme.TextSub end)

    SearchBtn.MouseButton1Click:Connect(function()
        SearchOverlay.Visible = true
        SearchInputBox.Text = ''
        TweenService:Create(SearchOverlay, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {GroupTransparency = 0}):Play()
        SearchInputBox:CaptureFocus()
    end)

    SearchOverlay.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            local pos = input.Position
            local cx1, cy1 = SearchPanel.AbsolutePosition.X, SearchPanel.AbsolutePosition.Y
            local cx2, cy2 = cx1 + SearchPanel.AbsoluteSize.X, cy1 + SearchPanel.AbsoluteSize.Y
            if not (pos.X >= cx1 and pos.X <= cx2 and pos.Y >= cy1 and pos.Y <= cy2) then
                TweenService:Create(SearchOverlay, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {GroupTransparency = 1}):Play()
                task.delay(0.3, function() SearchOverlay.Visible = false end)
            end
        end
    end)

    local PopulateSearch = function(query)
        local cList = SearchScroll:GetChildren()
        for i = 1, #cList do
            local v = cList[i]
            if v:IsA('TextButton') then v:Destroy() end
        end
        if query == '' then return end
        
        query = query:lower()
        for i = 1, #WindowObj.ElementsList do
            local elementData = WindowObj.ElementsList[i]
            if string.find(elementData.Name:lower(), query) then
                local sBtn = createInstance('TextButton', {
                    Parent = SearchScroll,
                    BackgroundColor3 = Theme.ElementBG,
                    Size = UDim2.new(1, 0, 0, 34),
                    Text = '',
                    AutoButtonColor = false
                })
                createInstance('UICorner', {Parent = sBtn, CornerRadius = UDim.new(0, 4)})
                
                local sText = createInstance('TextLabel', {
                    Parent = sBtn,
                    BackgroundTransparency = 1,
                    Position = UDim2.new(0, 10, 0, 0),
                    Size = UDim2.new(1, -20, 1, 0),
                    Font = Enum.Font.GothamMedium,
                    Text = elementData.Name .. "  <font color='rgb(120,120,120)'>[" .. elementData.Tab.Name .. "]</font>",
                    RichText = true,
                    TextColor3 = Theme.TextMain,
                    TextSize = 13,
                    TextXAlignment = Enum.TextXAlignment.Left
                })

                regTheme(sBtn, function() sBtn.BackgroundColor3 = Theme.ElementBG end)
                regTheme(sText, function() sText.TextColor3 = Theme.TextMain end)

                sBtn.MouseEnter:Connect(function()
                    TweenService:Create(sBtn, TweenInfo.new(0.2), {BackgroundColor3 = GetDarkerColor(Theme.ElementBG, 0.8)}):Play()
                end)
                sBtn.MouseLeave:Connect(function()
                    TweenService:Create(sBtn, TweenInfo.new(0.2), {BackgroundColor3 = Theme.ElementBG}):Play()
                end)

                sBtn.MouseButton1Click:Connect(function()
                    TweenService:Create(SearchOverlay, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {GroupTransparency = 1}):Play()
                    task.delay(0.3, function() SearchOverlay.Visible = false end)
                    
                    elementData.Tab.Select()
                    
                    task.wait(0.1) 
                    local targetY = elementData.Frame.AbsolutePosition.Y - elementData.Tab.Page.AbsolutePosition.Y + elementData.Tab.Page.CanvasPosition.Y - (elementData.Tab.Page.AbsoluteWindowSize.Y / 2) + (elementData.Frame.AbsoluteSize.Y / 2)
                    TweenService:Create(elementData.Tab.Page, TweenInfo.new(0.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {
                        CanvasPosition = Vector2.new(0, math.max(0, targetY))
                    }):Play()

                    local origColor = elementData.Frame.BackgroundColor3
                    TweenService:Create(elementData.Frame, TweenInfo.new(0.3), {BackgroundColor3 = Theme.Accent}):Play()
                    task.delay(0.6, function()
                        if elementData.Frame then
                            TweenService:Create(elementData.Frame, TweenInfo.new(0.5), {BackgroundColor3 = origColor}):Play()
                        end
                    end)
                end)
            end
        end
    end

    SearchInputBox:GetPropertyChangedSignal('Text'):Connect(function()
        PopulateSearch(SearchInputBox.Text)
    end)

    local startX = TitleLabel.Position.X.Offset + titleBounds.X + 25
    local endX = 580 - 15 - (profileBounds.X + 42) - 15 - 30
    local subTabsWidth = endX - startX

    local SubTabs = createInstance('Frame', {
        Parent = Topbar,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, startX, 0, 0),
        Size = UDim2.new(0, subTabsWidth, 1, 0)
    })

    createInstance('UIListLayout', {
        Parent = SubTabs,
        FillDirection = Enum.FillDirection.Horizontal,
        SortOrder = Enum.SortOrder.LayoutOrder,
        Padding = UDim.new(0, 15),
        VerticalAlignment = Enum.VerticalAlignment.Center
    })

    local subTabItems = {'Home', 'UI Settings', 'Configs'}
    local activeSubTab = 'Home'
    local MasterContainers = {}

    local BodyContainer = createInstance('Frame', {
        Name = 'BodyContainer',
        Parent = MainGroup,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 0, 0, 48),
        Size = UDim2.new(1, 0, 1, -48),
        ClipsDescendants = true
    })

    local CreateTopSubTab = function(text)
        local SubContainer = createInstance('CanvasGroup', {
            Name = text .. 'Container',
            Parent = BodyContainer,
            BackgroundTransparency = 1,
            Position = UDim2.new(0, 0, 0, 0),
            Size = UDim2.new(1, 0, 1, 0),
            Visible = (text == activeSubTab),
            GroupTransparency = (text == activeSubTab) and 0 or 1
        })
        MasterContainers[text] = SubContainer

        local tabBtn = createInstance('ImageButton', {
            Name = text .. 'Tab',
            Parent = SubTabs,
            BackgroundTransparency = 1,
            AutoButtonColor = false,
            Image = ''
        })

        local labelBounds = TextService:GetTextSize(text, 12, Enum.Font.GothamMedium, Vector2.new(1000, 48))
        tabBtn.Size = UDim2.new(0, labelBounds.X + 10, 1, 0)

        local tabLabel = createInstance('TextLabel', {
            Parent = tabBtn,
            BackgroundTransparency = 1,
            Size = UDim2.new(1, 0, 1, 0),
            Font = Enum.Font.GothamMedium,
            Text = text,
            TextSize = 12,
            TextColor3 = (text == activeSubTab) and Theme.TextMain or Theme.TextSub
        })
        
        regTheme(tabLabel, function()
            if activeSubTab == text then tabLabel.TextColor3 = Theme.TextMain end
        end)

        local underline = createInstance('Frame', {
            Parent = tabBtn,
            BackgroundColor3 = Theme.Accent,
            BorderSizePixel = 0,
            AnchorPoint = Vector2.new(0.5, 1),
            Position = UDim2.new(0.5, 0, 1, -2),
            Size = (text == activeSubTab) and UDim2.new(1, 0, 0, 2) or UDim2.new(0, 0, 0, 2),
            BackgroundTransparency = (text == activeSubTab) and 0 or 1
        })
        
        regTheme(underline, function() underline.BackgroundColor3 = Theme.Accent end)

        tabBtn.MouseEnter:Connect(function()
            if activeSubTab ~= text then
                TweenService:Create(tabLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextMain}):Play()
                TweenService:Create(underline, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Size = UDim2.new(0.8, 0, 0, 2), BackgroundTransparency = 0.3}):Play()
            end
        end)

        tabBtn.MouseLeave:Connect(function()
            if activeSubTab ~= text then
                TweenService:Create(tabLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextSub}):Play()
                TweenService:Create(underline, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Size = UDim2.new(0, 0, 0, 2), BackgroundTransparency = 1}):Play()
            end
        end)

        tabBtn.MouseButton1Click:Connect(function()
            if activeSubTab ~= text then
                local prevActive = activeSubTab
                activeSubTab = text
                
                local prevBtn = SubTabs:FindFirstChild(prevActive .. 'Tab')
                if prevBtn then
                    TweenService:Create(prevBtn.TextLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextSub}):Play()
                    TweenService:Create(prevBtn.Frame, TweenInfo.new(0.2), {Size = UDim2.new(0, 0, 0, 2), BackgroundTransparency = 1}):Play()
                end

                TweenService:Create(tabLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextMain}):Play()
                TweenService:Create(underline, TweenInfo.new(0.2), {Size = UDim2.new(1, 0, 0, 2), BackgroundTransparency = 0}):Play()
                
                local prevContainer = MasterContainers[prevActive]
                if prevContainer then
                    TweenService:Create(prevContainer, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.In), {Position = UDim2.new(0, 0, 0, -15), GroupTransparency = 1}):Play()
                    task.delay(0.25, function() if activeSubTab ~= prevActive then prevContainer.Visible = false end end)
                end

                local newContainer = MasterContainers[text]
                if newContainer then
                    newContainer.Visible = true
                    newContainer.Position = UDim2.new(0, 0, 0, 15)
                    newContainer.GroupTransparency = 1
                    TweenService:Create(newContainer, TweenInfo.new(0.4, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, 0, 0, 0), GroupTransparency = 0}):Play()
                end
            end
        end)
    end

    for i = 1, #subTabItems do CreateTopSubTab(subTabItems[i]) end

    local CreateElementBuilder = function(PageTarget, ParentTab)
        local Builder = {}

        Builder.CreateDivider = function(self)
            local DivContainer = createInstance('Frame', {
                Parent = PageTarget,
                BackgroundTransparency = 1,
                Size = UDim2.new(1, 0, 0, 14)
            })
            local Line = createInstance('Frame', {
                Parent = DivContainer,
                BackgroundColor3 = Theme.Border,
                BorderSizePixel = 0,
                AnchorPoint = Vector2.new(0.5, 0.5),
                Position = UDim2.new(0.5, 0, 0.5, 0),
                Size = UDim2.new(1, -20, 0, 2)
            })
            createInstance('UICorner', {Parent = Line, CornerRadius = UDim.new(0, 1)})
            regTheme(Line, function()
                if Line then Line.BackgroundColor3 = Theme.Border end
            end)
        end

        Builder.CreateButton = function(self, options)
            local BtnName = options.Name or 'Button'
            local Callback = options.Callback or function() end

            local BtnFrame = createInstance('ImageButton', {
                Parent = PageTarget,
                BackgroundColor3 = Theme.ElementBG,
                Size = UDim2.new(1, 0, 0, 36),
                AutoButtonColor = false,
                Image = ''
            })
            createInstance('UICorner', {Parent = BtnFrame, CornerRadius = UDim.new(0, 4)})
            regTheme(BtnFrame, function() BtnFrame.BackgroundColor3 = Theme.ElementBG end)

            local TextLabel = createInstance('TextLabel', {
                Parent = BtnFrame,
                BackgroundTransparency = 1,
                Size = UDim2.new(1, 0, 1, 0),
                Font = Enum.Font.GothamMedium,
                Text = BtnName,
                TextColor3 = Theme.TextSub,
                TextSize = 13
            })
            regTheme(TextLabel, function() TextLabel.TextColor3 = Theme.TextSub end)

            SetupTooltip(BtnFrame, options.Tip)
            table.insert(WindowObj.ElementsList, {Name = BtnName, Frame = BtnFrame, Tab = ParentTab})

            BtnFrame.MouseEnter:Connect(function()
                TweenService:Create(BtnFrame, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {BackgroundColor3 = GetDarkerColor(Theme.ElementBG, 0.8)}):Play()
                TweenService:Create(TextLabel, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {TextColor3 = Theme.TextMain}):Play()
            end)
            BtnFrame.MouseLeave:Connect(function()
                TweenService:Create(BtnFrame, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {BackgroundColor3 = Theme.ElementBG}):Play()
                TweenService:Create(TextLabel, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {TextColor3 = Theme.TextSub}):Play()
            end)
            BtnFrame.MouseButton1Down:Connect(function()
                TweenService:Create(BtnFrame, TweenInfo.new(0.1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {BackgroundColor3 = Theme.Accent}):Play()
                TweenService:Create(TextLabel, TweenInfo.new(0.1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {TextColor3 = Color3.fromRGB(255, 255, 255)}):Play()
            end)
            BtnFrame.MouseButton1Click:Connect(function()
                TweenService:Create(BtnFrame, TweenInfo.new(0.2, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {BackgroundColor3 = GetDarkerColor(Theme.ElementBG, 0.8)}):Play()
                Callback()
            end)
        end

        Builder.CreateTextbox = function(self, options)
            local ElementName = options.Name or 'Textbox'
            local Default = options.Default or ''
            local UseLetter = options.UseLetter
            local UseNumber = options.UseNumber
            local Callback = options.Callback or function() end

            local Element = { Value = Default }
            AkenaLib.Flags[ElementName] = Element

            local Container = createInstance('Frame', {
                Parent = PageTarget,
                BackgroundColor3 = Theme.ElementBG,
                Size = UDim2.new(1, 0, 0, 36)
            })
            createInstance('UICorner', {Parent = Container, CornerRadius = UDim.new(0, 4)})
            regTheme(Container, function() Container.BackgroundColor3 = Theme.ElementBG end)
            table.insert(WindowObj.ElementsList, {Name = ElementName, Frame = Container, Tab = ParentTab})

            local labelBounds = TextService:GetTextSize(ElementName, 13, Enum.Font.GothamMedium, Vector2.new(1000, 36))

            local LabelText = createInstance('TextLabel', {
                Parent = Container,
                BackgroundTransparency = 1,
                Position = UDim2.new(0, 12, 0, 0),
                Size = UDim2.new(0, labelBounds.X + 5, 1, 0),
                Font = Enum.Font.GothamMedium,
                Text = ElementName,
                TextColor3 = Theme.TextSub,
                TextSize = 13,
                TextXAlignment = Enum.TextXAlignment.Left
            })
            regTheme(LabelText, function() LabelText.TextColor3 = Theme.TextSub end)

            local ValBox = createInstance('Frame', {
                Parent = Container,
                BackgroundColor3 = Color3.fromRGB(35, 35, 35),
                AnchorPoint = Vector2.new(1, 0.5),
                Position = UDim2.new(1, -6, 0.5, 0),
                Size = UDim2.new(0, 120, 0, 24)
            })
            createInstance('UICorner', {Parent = ValBox, CornerRadius = UDim.new(0, 4)})
            regTheme(ValBox, function() ValBox.BackgroundColor3 = Theme.MainBG end)
            
            local ValBoxStroke = createInstance('UIStroke', {Parent = ValBox, Color = Theme.Border})
            regTheme(ValBoxStroke, function() ValBoxStroke.Color = Theme.Border end)

            local TextBox = createInstance('TextBox', {
                Parent = ValBox,
                BackgroundTransparency = 1,
                Position = UDim2.new(0, 0, 0, 0),
                Size = UDim2.new(1, -6, 1, 0),
                Font = Enum.Font.Gotham,
                Text = Default,
                PlaceholderText = 'Type...',
                PlaceholderColor3 = Color3.fromRGB(150, 150, 150),
                TextColor3 = Theme.TextMain,
                TextSize = 12,
                TextXAlignment = Enum.TextXAlignment.Right,
                ClearTextOnFocus = false
            })
            regTheme(TextBox, function() TextBox.TextColor3 = Theme.TextMain end)

            SetupTooltip(Container, options.Tip)

            TextBox:GetPropertyChangedSignal('Text'):Connect(function()
                local original = TextBox.Text
                local cleaned = original
                if UseLetter and not UseNumber then
                    cleaned = original:gsub('[^%a%s]', '')
                elseif UseNumber and not UseLetter then
                    cleaned = original:gsub('[^%d%.%-]', '')
                elseif UseLetter and UseNumber then
                    cleaned = original:gsub('[^%w%s%_%-]', '')
                end
                if original ~= cleaned then TextBox.Text = cleaned end
            end)

            TextBox.FocusLost:Connect(function()
                Element.Value = TextBox.Text
                AkenaLib.Flags[ElementName].Value = Element.Value
                Callback(Element.Value)
            end)
            
            function Element:Set(val)
                TextBox.Text = val
                Element.Value = val
                AkenaLib.Flags[ElementName].Value = val
                Callback(val)
            end

            return Element
        end

        Builder.CreateSlider = function(self, options)
            local ElementName = options.Name or 'Slider'
            local Min = options.Min or 0
            local Max = options.Max or 100
            local Default = options.Default or 35
            local Increment = options.Increment or 1
            local Suffix = options.Suffix or ''
            local Callback = options.Callback or function() end

            local Element = { Value = Default }
            AkenaLib.Flags[ElementName] = Element

            local Container = createInstance('Frame', {
                Parent = PageTarget,
                BackgroundColor3 = Theme.ElementBG,
                Size = UDim2.new(1, 0, 0, 36)
            })
            createInstance('UICorner', {Parent = Container, CornerRadius = UDim.new(0, 4)})
            regTheme(Container, function() Container.BackgroundColor3 = Theme.ElementBG end)
            table.insert(WindowObj.ElementsList, {Name = ElementName, Frame = Container, Tab = ParentTab})

            local labelBounds = TextService:GetTextSize(ElementName, 13, Enum.Font.GothamMedium, Vector2.new(1000, 36))

            local LabelText = createInstance('TextLabel', {
                Parent = Container,
                BackgroundTransparency = 1,
                Position = UDim2.new(0, 12, 0, 0),
                Size = UDim2.new(0, labelBounds.X + 5, 1, 0),
                Font = Enum.Font.GothamMedium,
                Text = ElementName,
                TextColor3 = Theme.TextSub,
                TextSize = 13,
                TextXAlignment = Enum.TextXAlignment.Left
            })
            regTheme(LabelText, function() LabelText.TextColor3 = Theme.TextSub end)

            local ValBox = createInstance('Frame', {
                Parent = Container,
                BackgroundColor3 = Color3.fromRGB(35, 35, 35),
                AnchorPoint = Vector2.new(1, 0.5),
                Position = UDim2.new(1, -6, 0.5, 0),
                Size = UDim2.new(0, 40, 0, 22)
            })
            createInstance('UICorner', {Parent = ValBox, CornerRadius = UDim.new(0, 4)})
            regTheme(ValBox, function() ValBox.BackgroundColor3 = Theme.MainBG end)
            
            local ValBoxStroke = createInstance('UIStroke', {Parent = ValBox, Color = Theme.Border})
            regTheme(ValBoxStroke, function() ValBoxStroke.Color = Theme.Border end)

            local ValTextBox = createInstance('TextBox', {
                Parent = ValBox,
                BackgroundTransparency = 1,
                Size = UDim2.new(1, 0, 1, 0),
                Font = Enum.Font.Gotham,
                Text = tostring(Default) .. Suffix,
                TextColor3 = Theme.TextSub,
                TextSize = 11,
                ClearTextOnFocus = false
            })
            regTheme(ValTextBox, function() ValTextBox.TextColor3 = Theme.TextSub end)

            local sliderStartOffset = 12 + labelBounds.X + 15
            local sliderEndPadding = 6 + 40 + 15

            local TrackBox = createInstance('ImageButton', {
                Parent = Container,
                BackgroundColor3 = Color3.fromRGB(45, 45, 45),
                AnchorPoint = Vector2.new(0, 0.5),
                Position = UDim2.new(0, sliderStartOffset, 0.5, 0),
                Size = UDim2.new(1, -(sliderStartOffset + sliderEndPadding), 0, 6),
                AutoButtonColor = false,
                Image = ''
            })
            createInstance('UICorner', {Parent = TrackBox, CornerRadius = UDim.new(1, 0)})
            regTheme(TrackBox, function() TrackBox.BackgroundColor3 = Theme.DropdownListStroke end)

            local FillBox = createInstance('Frame', {
                Parent = TrackBox,
                BackgroundColor3 = Theme.Accent,
                Size = UDim2.new((Default - Min) / (Max - Min), 0, 1, 0)
            })
            createInstance('UICorner', {Parent = FillBox, CornerRadius = UDim.new(1, 0)})
            
            regTheme(FillBox, function() FillBox.BackgroundColor3 = Theme.Accent end)

            SetupTooltip(Container, options.Tip)

            local SetValue = function(val)
                val = math.clamp(val, Min, Max)
                val = math.floor((val / Increment) + 0.5) * Increment
                local percent = (val - Min) / (Max - Min)
                TweenService:Create(FillBox, TweenInfo.new(0.15, Enum.EasingStyle.Quad), {Size = UDim2.new(percent, 0, 1, 0)}):Play()
                ValTextBox.Text = tostring(val) .. Suffix
                Element.Value = val
                AkenaLib.Flags[ElementName].Value = val
                Callback(val)
            end

            local UpdateSlider = function(input)
                local percent = math.clamp((input.Position.X - TrackBox.AbsolutePosition.X) / TrackBox.AbsoluteSize.X, 0, 1)
                local value = Min + ((Max - Min) * percent)
                SetValue(value)
            end

            local dragging = false
            TrackBox.InputBegan:Connect(function(input)
                if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                    dragging = true
                    UpdateSlider(input)
                end
            end)
            UserInputService.InputEnded:Connect(function(input)
                if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = false end
            end)
            UserInputService.InputChanged:Connect(function(input)
                if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then UpdateSlider(input) end
            end)

            ValTextBox.FocusLost:Connect(function()
                local numStr = string.match(ValTextBox.Text, '^%-?%d+%.?%d*')
                local num = tonumber(numStr) or Default
                SetValue(num)
            end)
            
            function Element:Set(val) SetValue(val) end
            return Element
        end

        Builder.CreateToggle = function(self, options)
            local ElementName = options.Name or 'Toggle'
            local Default = options.Default or false
            local Keybind = options.Keybind
            local Callback = options.Callback or function() end
            
            local state = Default
            local currentBind = Keybind

            local Element = { Value = Default }
            AkenaLib.Flags[ElementName] = Element

            local TogFrame = createInstance('ImageButton', {
                Parent = PageTarget,
                BackgroundColor3 = Theme.ElementBG,
                Size = UDim2.new(1, 0, 0, 36),
                AutoButtonColor = false,
                Image = ''
            })
            createInstance('UICorner', {Parent = TogFrame, CornerRadius = UDim.new(0, 4)})
            regTheme(TogFrame, function() TogFrame.BackgroundColor3 = Theme.ElementBG end)
            table.insert(WindowObj.ElementsList, {Name = ElementName, Frame = TogFrame, Tab = ParentTab})

            local TitleLabel = createInstance('TextLabel', {
                Parent = TogFrame,
                BackgroundTransparency = 1,
                Position = UDim2.new(0, 12, 0, 0),
                Size = UDim2.new(1, -120, 1, 0),
                Font = Enum.Font.GothamMedium,
                Text = ElementName,
                TextColor3 = Theme.TextSub,
                TextSize = 13,
                TextXAlignment = Enum.TextXAlignment.Left
            })
            regTheme(TitleLabel, function()
                TitleLabel.TextColor3 = state and Theme.TextMain or Theme.TextSub
            end)

            local Switch = createInstance('Frame', {
                Parent = TogFrame,
                BackgroundColor3 = Color3.fromRGB(20, 20, 20),
                AnchorPoint = Vector2.new(1, 0.5),
                Position = UDim2.new(1, -12, 0.5, 0),
                Size = UDim2.new(0, 28, 0, 10)
            })
            createInstance('UICorner', {Parent = Switch, CornerRadius = UDim.new(1, 0)})

            local Knob = createInstance('Frame', {
                Parent = Switch,
                BackgroundColor3 = state and GetDarkerColor(Theme.Accent, 0.4) or Color3.fromRGB(150, 150, 150),
                AnchorPoint = Vector2.new(0, 0.5),
                Position = state and UDim2.new(1, -14, 0.5, 0) or UDim2.new(0, -2, 0.5, 0),
                Size = UDim2.new(0, 16, 0, 16)
            })
            createInstance('UICorner', {Parent = Knob, CornerRadius = UDim.new(1, 0)})
            
            regTheme(Switch, function()
                if state then
                    Switch.BackgroundColor3 = GetDarkerColor(Theme.Accent, 0.4)
                    Knob.BackgroundColor3 = Theme.Accent
                else
                    Switch.BackgroundColor3 = Theme.MainBG
                    Knob.BackgroundColor3 = Color3.fromRGB(150, 150, 150)
                end
            end)

            SetupTooltip(TogFrame, options.Tip)

            local FireToggle = function(skipAnim)
                local speed = skipAnim and 0 or 0.2
                TweenService:Create(Switch, TweenInfo.new(speed), {BackgroundColor3 = state and GetDarkerColor(Theme.Accent, 0.4) or Theme.MainBG}):Play()
                TweenService:Create(Knob, TweenInfo.new(speed), {Position = state and UDim2.new(1, -14, 0.5, 0) or UDim2.new(0, -2, 0.5, 0), BackgroundColor3 = state and Theme.Accent or Color3.fromRGB(150, 150, 150)}):Play()
                TweenService:Create(TitleLabel, TweenInfo.new(speed), {TextColor3 = state and Theme.TextMain or Theme.TextSub}):Play()
                Element.Value = state
                AkenaLib.Flags[ElementName].Value = state
            end
            FireToggle(true)

            TogFrame.MouseButton1Click:Connect(function()
                state = not state
                Callback(state)
                FireToggle(false)
            end)

            if Keybind then
                local BindContainer = createInstance('Frame', {
                    Parent = TogFrame,
                    AnchorPoint = Vector2.new(1, 0.5),
                    Position = UDim2.new(1, -55, 0.5, 0),
                    Size = UDim2.new(0, 45, 0, 22),
                    BackgroundColor3 = Color3.fromRGB(35, 35, 35)
                })
                createInstance('UICorner', {Parent = BindContainer, CornerRadius = UDim.new(0, 4)})
                regTheme(BindContainer, function() BindContainer.BackgroundColor3 = Theme.MainBG end)
                
                local BindContainerStroke = createInstance('UIStroke', {Parent = BindContainer, Color = Theme.Border})
                regTheme(BindContainerStroke, function() BindContainerStroke.Color = Theme.Border end)

                local BindBtn = createInstance('TextButton', {
                    Parent = BindContainer,
                    BackgroundTransparency = 1,
                    Size = UDim2.new(1, 0, 1, 0),
                    Text = currentBind and currentBind.Name or '',
                    Font = Enum.Font.Gotham,
                    TextColor3 = Theme.TextSub,
                    TextSize = 11
                })

                local UpdateBindSize = function()
                    local bindName = currentBind and currentBind.Name or 'None'
                    BindBtn.Text = bindName
                    local textBounds = TextService:GetTextSize(bindName, 11, Enum.Font.Gotham, Vector2.new(1000, 22))
                    BindContainer.Size = UDim2.new(0, math.max(textBounds.X + 16, 40), 0, 22)
                end
                UpdateBindSize()

                local isBinding = false
                BindBtn.MouseButton1Click:Connect(function()
                    isBinding = true
                    BindBtn.Text = '...'
                    BindContainer.Size = UDim2.new(0, 40, 0, 22)
                end)

                UserInputService.InputBegan:Connect(function(input, gpe)
                    if isBinding and (input.UserInputType == Enum.UserInputType.Keyboard or input.UserInputType == Enum.UserInputType.Gamepad1) then
                        currentBind = input.KeyCode
                        isBinding = false
                        UpdateBindSize()
                        Callback(state)
                    elseif not gpe and currentBind and input.KeyCode == currentBind then
                        state = not state
                        Callback(state)
                        FireToggle(false)
                    end
                end)
            end
            
            function Element:Set(val)
                state = val
                Callback(state)
                FireToggle(true)
            end

            return Element
        end

        Builder.CreateDropdown = function(self, options)
            local ElementName = options.Name or 'Dropdown'
            local DropOptions = options.Options or {}
            local Default = options.Default
            local MultiSelect = options.MultiSelect or false
            local Callback = options.Callback or function() end

            local currentSelection
            if MultiSelect then
                currentSelection = {}
                if type(Default) == 'table' then
                    for i = 1, #Default do
                        table.insert(currentSelection, getStringValue(Default[i]))
                    end
                elseif type(Default) == 'string' and Default ~= '' then
                    table.insert(currentSelection, Default)
                end
            else
                if Default ~= nil then
                    currentSelection = type(Default) == 'table' and tostring(Default or '') or tostring(Default)
                else
                    currentSelection = type(DropOptions) == 'table' and tostring(DropOptions or '') or ''
                end
                if type(currentSelection) == 'table' then currentSelection = 'None' end
            end
            
            local Element = { Value = currentSelection }
            AkenaLib.Flags[ElementName] = Element

            local Container = createInstance('ImageButton', {
                Parent = PageTarget,
                BackgroundColor3 = Theme.ElementBG,
                Size = UDim2.new(1, 0, 0, 36),
                AutoButtonColor = false,
                Image = ''
            })
            createInstance('UICorner', {Parent = Container, CornerRadius = UDim.new(0, 4)})
            regTheme(Container, function() Container.BackgroundColor3 = Theme.ElementBG end)
            table.insert(WindowObj.ElementsList, {Name = ElementName, Frame = Container, Tab = ParentTab})

            local TitleLabel = createInstance('TextLabel', {
                Parent = Container,
                BackgroundTransparency = 1,
                Position = UDim2.new(0, 12, 0, 0),
                Size = UDim2.new(1, -120, 1, 0),
                Font = Enum.Font.GothamMedium,
                Text = ElementName,
                TextColor3 = Theme.TextSub,
                TextSize = 13,
                TextXAlignment = Enum.TextXAlignment.Left
            })
            regTheme(TitleLabel, function() TitleLabel.TextColor3 = Theme.TextSub end)

            local SelectedBox = createInstance('Frame', {
                Parent = Container,
                BackgroundColor3 = Color3.fromRGB(22, 22, 22),
                AnchorPoint = Vector2.new(1, 0.5),
                Position = UDim2.new(1, -6, 0.5, 0),
                Size = UDim2.new(0, 100, 0, 24)
            })
            createInstance('UICorner', {Parent = SelectedBox, CornerRadius = UDim.new(0, 4)})
            regTheme(SelectedBox, function() SelectedBox.BackgroundColor3 = Theme.MainBG end)
            
            local SelectedBoxStroke = createInstance('UIStroke', {Parent = SelectedBox, Color = Theme.Border})
            regTheme(SelectedBoxStroke, function() SelectedBoxStroke.Color = Theme.Border end)

            local SelectedLabel = createInstance('TextLabel', {
                Parent = SelectedBox,
                BackgroundTransparency = 1,
                Size = UDim2.new(1, -20, 1, 0),
                Position = UDim2.new(0, 8, 0, 0),
                Font = Enum.Font.Gotham,
                TextColor3 = Theme.TextMain,
                TextSize = 11,
                TextXAlignment = Enum.TextXAlignment.Left,
                TextTruncate = Enum.TextTruncate.AtEnd
            })
            regTheme(SelectedLabel, function() SelectedLabel.TextColor3 = Theme.TextMain end)
            
            local UpdateLabel = function()
                if MultiSelect then
                    SelectedLabel.Text = #currentSelection > 0 and table.concat(currentSelection, ', ') or 'None'
                else
                    SelectedLabel.Text = (currentSelection == '' or currentSelection == nil) and 'None' or tostring(currentSelection)
                end
            end
            UpdateLabel()

            local Icon = createInstance('TextLabel', {
                Parent = SelectedBox,
                BackgroundTransparency = 1,
                AnchorPoint = Vector2.new(1, 0.5),
                Position = UDim2.new(1, -5, 0.5, 0),
                Size = UDim2.new(0, 16, 0, 16),
                Font = Enum.Font.Gotham,
                Text = '+',
                TextColor3 = Theme.TextSub,
                TextSize = 16
            })
            regTheme(Icon, function() Icon.TextColor3 = Theme.TextSub end)

            local ListCanvas = createInstance('CanvasGroup', {
                Parent = ScreenGui,
                BackgroundTransparency = 1,
                ZIndex = 100,
                Size = UDim2.new(0, 0, 0, 0),
                GroupTransparency = 1,
                Visible = false
            })
            
            local LCScale = createInstance('UIScale', {Parent = ListCanvas, Scale = CurrentScale})
            table.insert(ScalesToUpdate, LCScale)
            createInstance('UICorner', {Parent = ListCanvas, CornerRadius = UDim.new(0, 4)})

            local ListFrame = createInstance('ScrollingFrame', {
                Parent = ListCanvas,
                BackgroundColor3 = Theme.DropdownListBG,
                Size = UDim2.new(1, 0, 1, 0),
                ZIndex = 100,
                ScrollBarThickness = 2,
                BorderSizePixel = 0,
                AutomaticCanvasSize = Enum.AutomaticSize.Y
            })
            local ListFrameStroke = createInstance('UIStroke', {Parent = ListFrame, Color = Theme.DropdownListStroke})
            
            regTheme(ListFrame, function() 
                ListFrame.BackgroundColor3 = Theme.DropdownListBG
                ListFrameStroke.Color = Theme.DropdownListStroke
            end)
            
            local CanvasLayout = createInstance('Frame', {
                Parent = ListFrame,
                BackgroundTransparency = 1,
                Size = UDim2.new(1, 0, 0, 0),
                AutomaticSize = Enum.AutomaticSize.Y
            })
            createInstance('UIListLayout', {Parent = CanvasLayout, SortOrder = Enum.SortOrder.LayoutOrder})

            SetupTooltip(Container, options.Tip)

            local expanded = false
            local OptionsRendered = {}

            local RefreshOptions = function()
                local cList = CanvasLayout:GetChildren()
                for i = 1, #cList do
                    local v = cList[i]
                    if v:IsA('TextButton') then v:Destroy() end
                end
                table.clear(OptionsRendered)

                for i = 1, #DropOptions do
                    local strOpt = tostring(DropOptions[i])
                    
                    local Option = createInstance('TextButton', {
                        Parent = CanvasLayout,
                        BackgroundTransparency = 1,
                        Size = UDim2.new(1, 0, 0, 26),
                        Text = '',
                        ZIndex = 101
                    })

                    local isSel = false
                    if MultiSelect then
                        isSel = table.find(currentSelection, strOpt) ~= nil
                    else
                        isSel = currentSelection == strOpt
                    end
                    
                    local OptCheck = createInstance('ImageLabel', {
                        Parent = Option,
                        BackgroundTransparency = 1,
                        Position = isSel and UDim2.new(0, 8, 0.5, -7) or UDim2.new(0, 0, 0.5, -7),
                        Size = UDim2.new(0, 14, 0, 14),
                        Image = 'rbxassetid://6031094667',
                        ImageColor3 = Theme.TextMain,
                        ImageTransparency = isSel and 0 or 1,
                        ZIndex = 101
                    })
                    regTheme(OptCheck, function() OptCheck.ImageColor3 = Theme.TextMain end)
                    
                    local OptText = createInstance('TextLabel', {
                        Parent = Option,
                        BackgroundTransparency = 1,
                        Size = UDim2.new(1, -30, 1, 0),
                        Position = UDim2.new(0, 28, 0, 0),
                        Font = Enum.Font.GothamMedium,
                        Text = strOpt,
                        TextColor3 = isSel and Theme.TextMain or Theme.TextSub,
                        TextSize = 13,
                        TextXAlignment = Enum.TextXAlignment.Left,
                        ZIndex = 101
                    })

                    table.insert(OptionsRendered, {
                        Value = strOpt,
                        Text = OptText,
                        Check = OptCheck,
                        Button = Option
                    })
                    
                    Option.MouseEnter:Connect(function()
                        TweenService:Create(OptText, TweenInfo.new(0.2), {TextColor3 = Theme.TextMain}):Play()
                    end)
                    Option.MouseLeave:Connect(function()
                        local active = false
                        if MultiSelect then active = table.find(currentSelection, strOpt) ~= nil else active = currentSelection == strOpt end
                        TweenService:Create(OptText, TweenInfo.new(0.2), {TextColor3 = active and Theme.TextMain or Theme.TextSub}):Play()
                    end)

                    Option.MouseButton1Click:Connect(function()
                        if MultiSelect then
                            local idx = table.find(currentSelection, strOpt)
                            if idx then 
                                table.remove(currentSelection, idx) 
                                OptText.TextColor3 = Theme.TextSub
                                TweenService:Create(OptCheck, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, 0, 0.5, -7), ImageTransparency = 1}):Play()
                            else 
                                table.insert(currentSelection, strOpt) 
                                OptText.TextColor3 = Theme.TextMain
                                TweenService:Create(OptCheck, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, 8, 0.5, -7), ImageTransparency = 0}):Play()
                            end
                        else
                            currentSelection = strOpt
                            expanded = false
                            TweenService:Create(Icon, TweenInfo.new(0.3), {Rotation = 0}):Play()
                            TweenService:Create(ListCanvas, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Size = UDim2.new(0, SelectedBox.AbsoluteSize.X, 0, 0), GroupTransparency = 1}):Play()
                            task.delay(0.3, function() if not expanded then ListCanvas.Visible = false end end)
                            
                            for k = 1, #OptionsRendered do
                                local renderData = OptionsRendered[k]
                                if renderData.Value == strOpt then
                                    renderData.Text.TextColor3 = Theme.TextMain
                                    TweenService:Create(renderData.Check, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, 8, 0.5, -7), ImageTransparency = 0}):Play()
                                else
                                    renderData.Text.TextColor3 = Theme.TextSub
                                    TweenService:Create(renderData.Check, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, 0, 0.5, -7), ImageTransparency = 1}):Play()
                                end
                            end
                        end
                        UpdateLabel()
                        Element.Value = currentSelection
                        AkenaLib.Flags[ElementName].Value = currentSelection
                        Callback(currentSelection)
                    end)
                end
                
                ListFrame.CanvasSize = UDim2.new(0, 0, 0, #DropOptions * 26)
            end

            RefreshOptions()

            Container.MouseButton1Click:Connect(function()
                expanded = not expanded
                if expanded then
                    RefreshOptions()
                    ListCanvas.Position = UDim2.new(0, SelectedBox.AbsolutePosition.X, 0, SelectedBox.AbsolutePosition.Y + (28 * CurrentScale))
                    local dropHeight = math.min(#DropOptions * 26, 150)
                    ListCanvas.Size = UDim2.new(0, SelectedBox.AbsoluteSize.X, 0, 0)
                    ListCanvas.GroupTransparency = 1
                    ListCanvas.Visible = true
                    TweenService:Create(ListCanvas, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Size = UDim2.new(0, SelectedBox.AbsoluteSize.X, 0, dropHeight), GroupTransparency = 0}):Play()
                else
                    TweenService:Create(ListCanvas, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Size = UDim2.new(0, SelectedBox.AbsoluteSize.X, 0, 0), GroupTransparency = 1}):Play()
                    task.delay(0.3, function() if not expanded then ListCanvas.Visible = false end end)
                end
                TweenService:Create(Icon, TweenInfo.new(0.3), {Rotation = expanded and 45 or 0}):Play()
            end)

            UserInputService.InputBegan:Connect(function(input)
                if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                    local pos = input.Position
                    if expanded and ListCanvas.Visible then
                        local x1 = ListCanvas.AbsolutePosition.X
                        local y1 = ListCanvas.AbsolutePosition.Y
                        local x2 = x1 + ListCanvas.AbsoluteSize.X
                        local y2 = y1 + ListCanvas.AbsoluteSize.Y
                        local cx1 = Container.AbsolutePosition.X
                        local cy1 = Container.AbsolutePosition.Y
                        local cx2 = cx1 + Container.AbsoluteSize.X
                        local cy2 = cy1 + Container.AbsoluteSize.Y
                        
                        if not (pos.X >= x1 and pos.X <= x2 and pos.Y >= y1 and pos.Y <= y2) and not (pos.X >= cx1 and pos.X <= cx2 and pos.Y >= cy1 and pos.Y <= cy2) then
                            expanded = false
                            TweenService:Create(ListCanvas, TweenInfo.new(0.3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Size = UDim2.new(0, SelectedBox.AbsoluteSize.X, 0, 0), GroupTransparency = 1}):Play()
                            TweenService:Create(Icon, TweenInfo.new(0.3), {Rotation = 0}):Play()
                            task.delay(0.3, function() if not expanded then ListCanvas.Visible = false end end)
                        end
                    end
                end
            end)
            
            function Element:Set(val)
                if MultiSelect then
                    currentSelection = type(val) == 'table' and val or {}
                else
                    currentSelection = getStringValue(val)
                end
                if type(currentSelection) == 'table' then currentSelection = 'None' end
                UpdateLabel()
                Element.Value = currentSelection
                AkenaLib.Flags[ElementName].Value = currentSelection
                RefreshOptions()
                Callback(currentSelection)
            end

            function Element:Refresh(newOptions)
                DropOptions = type(newOptions) == 'table' and newOptions or {}
                if MultiSelect then
                    local newSel = {}
                    for i = 1, #currentSelection do
                        local v = currentSelection[i]
                        if table.find(DropOptions, v) then table.insert(newSel, v) end
                    end
                    currentSelection = newSel
                else
                    if not table.find(DropOptions, currentSelection) then
                        currentSelection = getStringValue(DropOptions)
                    end
                end
                if type(currentSelection) == 'table' then currentSelection = 'None' end
                UpdateLabel()
                Element.Value = currentSelection
                AkenaLib.Flags[ElementName].Value = currentSelection
                RefreshOptions()
            end

            return Element
        end

        Builder.CreateColorpicker = function(self, options)
            local ElementName = options.Name or 'Colorpicker'
            local Default = options.Default or Color3.fromRGB(255, 255, 255)
            local Callback = options.Callback or function() end

            local Element = { Value = Default }
            AkenaLib.Flags[ElementName] = Element
            
            local currentColor = Default
            local h, s, v = Color3.toHSV(currentColor)

            local Container = createInstance('ImageButton', {
                Parent = PageTarget,
                BackgroundColor3 = Theme.ElementBG,
                Size = UDim2.new(1, 0, 0, 36),
                AutoButtonColor = false,
                Image = ''
            })
            createInstance('UICorner', {Parent = Container, CornerRadius = UDim.new(0, 4)})
            regTheme(Container, function() Container.BackgroundColor3 = Theme.ElementBG end)
            table.insert(WindowObj.ElementsList, {Name = ElementName, Frame = Container, Tab = ParentTab})

            local TitleLabel = createInstance('TextLabel', {
                Parent = Container,
                BackgroundTransparency = 1,
                Position = UDim2.new(0, 12, 0, 0),
                Size = UDim2.new(1, -120, 1, 0),
                Font = Enum.Font.GothamMedium,
                Text = ElementName,
                TextColor3 = Theme.TextSub,
                TextSize = 13,
                TextXAlignment = Enum.TextXAlignment.Left
            })
            regTheme(TitleLabel, function() TitleLabel.TextColor3 = Theme.TextSub end)

            local ColorView = createInstance('Frame', {
                Parent = Container,
                BackgroundColor3 = currentColor,
                AnchorPoint = Vector2.new(1, 0.5),
                Position = UDim2.new(1, -6, 0.5, 0),
                Size = UDim2.new(0, 40, 0, 20)
            })
            createInstance('UICorner', {Parent = ColorView, CornerRadius = UDim.new(0, 4)})
            local ColorViewStroke = createInstance('UIStroke', {Parent = ColorView, Color = Theme.Border})
            regTheme(ColorViewStroke, function() ColorViewStroke.Color = Theme.Border end)

            local FloatPicker = createInstance('Frame', {
                Parent = ScreenGui,
                BackgroundColor3 = Color3.fromRGB(25, 25, 25),
                Size = UDim2.new(0, 180, 0, 190),
                ZIndex = 100,
                Visible = false
            })
            
            local FloatPickerScale = createInstance('UIScale', {Parent = FloatPicker, Scale = CurrentScale})
            table.insert(ScalesToUpdate, FloatPickerScale)

            createInstance('UICorner', {Parent = FloatPicker, CornerRadius = UDim.new(0, 6)})
            local FloatPickerStroke = createInstance('UIStroke', {Parent = FloatPicker, Color = Theme.Border})
            regTheme(FloatPickerStroke, function() FloatPickerStroke.Color = Theme.Border end)
            regTheme(FloatPicker, function() FloatPicker.BackgroundColor3 = Theme.ElementBG end)

            local SatValMap = createInstance('ImageButton', {
                Parent = FloatPicker,
                BackgroundColor3 = Color3.fromHSV(h, 1, 1),
                Position = UDim2.new(0, 10, 0, 10),
                Size = UDim2.new(0, 130, 0, 130),
                Image = 'rbxassetid://4155801252',
                AutoButtonColor = false
            })
            createInstance('UICorner', {Parent = SatValMap, CornerRadius = UDim.new(0, 4)})

            local SVKnob = createInstance('Frame', {
                Parent = SatValMap,
                BackgroundColor3 = Color3.fromRGB(255, 255, 255),
                Size = UDim2.new(0, 4, 0, 4),
                AnchorPoint = Vector2.new(0.5, 0.5),
                Position = UDim2.new(s, 0, 1 - v, 0)
            })
            createInstance('UICorner', {Parent = SVKnob, CornerRadius = UDim.new(1, 0)})
            createInstance('UIStroke', {Parent = SVKnob, Color = Color3.fromRGB(0, 0, 0)})

            local HueMap = createInstance('ImageButton', {
                Parent = FloatPicker,
                Position = UDim2.new(0, 150, 0, 10),
                Size = UDim2.new(0, 20, 0, 130),
                BackgroundColor3 = Color3.fromRGB(255, 255, 255),
                AutoButtonColor = false,
                Image = ''
            })
            createInstance('UICorner', {Parent = HueMap, CornerRadius = UDim.new(0, 4)})

            createInstance('UIGradient', {
                Parent = HueMap,
                Color = ColorSequence.new({
                    ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
                    ColorSequenceKeypoint.new(0.167, Color3.fromRGB(255, 255, 0)),
                    ColorSequenceKeypoint.new(0.333, Color3.fromRGB(0, 255, 0)),
                    ColorSequenceKeypoint.new(0.5, Color3.fromRGB(0, 255, 255)),
                    ColorSequenceKeypoint.new(0.667, Color3.fromRGB(0, 0, 255)),
                    ColorSequenceKeypoint.new(0.833, Color3.fromRGB(255, 0, 255)),
                    ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 0, 0))
                }),
                Rotation = 90
            })

            local HueKnob = createInstance('Frame', {
                Parent = HueMap,
                BackgroundColor3 = Color3.fromRGB(255, 255, 255),
                Size = UDim2.new(1, 4, 0, 4),
                AnchorPoint = Vector2.new(0.5, 0.5),
                Position = UDim2.new(0.5, 0, 1 - h, 0)
            })
            createInstance('UIStroke', {Parent = HueKnob, Color = Color3.fromRGB(0, 0, 0)})

            local HexBox = createInstance('TextBox', {
                Parent = FloatPicker,
                Position = UDim2.new(0, 10, 0, 150),
                Size = UDim2.new(0, 75, 0, 24),
                BackgroundColor3 = Color3.fromRGB(35, 35, 35),
                TextColor3 = Color3.fromRGB(255, 255, 255),
                Font = Enum.Font.Gotham,
                TextSize = 11,
                Text = currentColor:ToHex(),
                ClearTextOnFocus = false
            })
            createInstance('UICorner', {Parent = HexBox, CornerRadius = UDim.new(0, 4)})
            regTheme(HexBox, function() HexBox.BackgroundColor3 = Theme.MainBG end)

            local RGBBox = createInstance('TextBox', {
                Parent = FloatPicker,
                Position = UDim2.new(0, 95, 0, 150),
                Size = UDim2.new(0, 75, 0, 24),
                BackgroundColor3 = Color3.fromRGB(35, 35, 35),
                TextColor3 = Color3.fromRGB(255, 255, 255),
                Font = Enum.Font.Gotham,
                TextSize = 11,
                Text = math.floor(currentColor.R*255)..', '..math.floor(currentColor.G*255)..', '..math.floor(currentColor.B*255),
                ClearTextOnFocus = false
            })
            createInstance('UICorner', {Parent = RGBBox, CornerRadius = UDim.new(0, 4)})
            regTheme(RGBBox, function() RGBBox.BackgroundColor3 = Theme.MainBG end)

            SetupTooltip(Container, options.Tip)

            local UpdateColor = function()
                currentColor = Color3.fromHSV(h, s, v)
                ColorView.BackgroundColor3 = currentColor
                SatValMap.BackgroundColor3 = Color3.fromHSV(h, 1, 1)
                HexBox.Text = currentColor:ToHex()
                RGBBox.Text = math.floor(currentColor.R*255)..', '..math.floor(currentColor.G*255)..', '..math.floor(currentColor.B*255)
                Element.Value = currentColor
                AkenaLib.Flags[ElementName].Value = currentColor
                Callback(currentColor)
            end

            HexBox.FocusLost:Connect(function()
                local success, color = pcall(function() return Color3.fromHex(HexBox.Text) end)
                if success then
                    currentColor = color
                    h, s, v = Color3.toHSV(currentColor)
                    SVKnob.Position = UDim2.new(s, 0, 1 - v, 0)
                    HueKnob.Position = UDim2.new(0.5, 0, 1 - h, 0)
                    UpdateColor()
                else
                    HexBox.Text = currentColor:ToHex()
                end
            end)

            RGBBox.FocusLost:Connect(function()
                local r, g, b = RGBBox.Text:match('(%d+)[%s,]+(%d+)[%s,]+(%d+)')
                if r and g and b then
                    currentColor = Color3.fromRGB(tonumber(r), tonumber(g), tonumber(b))
                    h, s, v = Color3.toHSV(currentColor)
                    SVKnob.Position = UDim2.new(s, 0, 1 - v, 0)
                    HueKnob.Position = UDim2.new(0.5, 0, 1 - h, 0)
                    UpdateColor()
                else
                    RGBBox.Text = math.floor(currentColor.R*255)..', '..math.floor(currentColor.G*255)..', '..math.floor(currentColor.B*255)
                end
            end)

            local draggingSV = false
            SatValMap.InputBegan:Connect(function(input)
                if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then draggingSV = true end
            end)
            local draggingHue = false
            HueMap.InputBegan:Connect(function(input)
                if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then draggingHue = true end
            end)
            UserInputService.InputEnded:Connect(function(input)
                if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                    draggingSV = false
                    draggingHue = false
                end
            end)
            UserInputService.InputChanged:Connect(function(input)
                if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
                    if draggingSV then
                        local pctX = math.clamp((input.Position.X - SatValMap.AbsolutePosition.X) / SatValMap.AbsoluteSize.X, 0, 1)
                        local pctY = math.clamp((input.Position.Y - SatValMap.AbsolutePosition.Y) / SatValMap.AbsoluteSize.Y, 0, 1)
                        s = pctX
                        v = 1 - pctY
                        SVKnob.Position = UDim2.new(s, 0, 1 - v, 0)
                        UpdateColor()
                    elseif draggingHue then
                        local pctY = math.clamp((input.Position.Y - HueMap.AbsolutePosition.Y) / HueMap.AbsoluteSize.Y, 0, 1)
                        h = 1 - pctY
                        HueKnob.Position = UDim2.new(0.5, 0, 1 - h, 0)
                        UpdateColor()
                    end
                end
            end)

            Container.MouseButton1Click:Connect(function()
                FloatPicker.Position = UDim2.new(0, ColorView.AbsolutePosition.X - (140 * CurrentScale), 0, ColorView.AbsolutePosition.Y + (28 * CurrentScale))
                FloatPicker.Visible = not FloatPicker.Visible
            end)

            UserInputService.InputBegan:Connect(function(input)
                if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                    local pos = input.Position
                    if FloatPicker.Visible then
                        local x1, y1 = FloatPicker.AbsolutePosition.X, FloatPicker.AbsolutePosition.Y
                        local x2, y2 = x1 + FloatPicker.AbsoluteSize.X, y1 + FloatPicker.AbsoluteSize.Y
                        local cx1, cy1 = Container.AbsolutePosition.X, Container.AbsolutePosition.Y
                        local cx2, cy2 = cx1 + Container.AbsoluteSize.X, cy1 + Container.AbsoluteSize.Y
                        if not (pos.X >= x1 and pos.X <= x2 and pos.Y >= y1 and pos.Y <= y2) and not (pos.X >= cx1 and pos.X <= cx2 and pos.Y >= cy1 and pos.Y <= cy2) then
                            FloatPicker.Visible = false
                        end
                    end
                end
            end)
            
            function Element:Set(val)
                currentColor = val
                h, s, v = Color3.toHSV(currentColor)
                SVKnob.Position = UDim2.new(s, 0, 1 - v, 0)
                HueKnob.Position = UDim2.new(0.5, 0, 1 - h, 0)
                UpdateColor()
            end

            return Element
        end

        Builder.CreateKeybind = function(self, options)
            local ElementName = options.Name or 'Keybind'
            local Default = options.Default or Enum.KeyCode.E
            local Callback = options.Callback or function() end
            local currentBind = Default
            
            local Element = { Value = currentBind }
            AkenaLib.Flags[ElementName] = Element

            local BindFrame = createInstance('Frame', {
                Parent = PageTarget,
                BackgroundColor3 = Theme.ElementBG,
                Size = UDim2.new(1, 0, 0, 36)
            })
            createInstance('UICorner', {Parent = BindFrame, CornerRadius = UDim.new(0, 4)})
            regTheme(BindFrame, function() BindFrame.BackgroundColor3 = Theme.ElementBG end)
            table.insert(WindowObj.ElementsList, {Name = ElementName, Frame = BindFrame, Tab = ParentTab})

            local TitleLabel = createInstance('TextLabel', {
                Parent = BindFrame,
                BackgroundTransparency = 1,
                Position = UDim2.new(0, 12, 0, 0),
                Size = UDim2.new(1, -120, 1, 0),
                Font = Enum.Font.GothamMedium,
                Text = ElementName,
                TextColor3 = Theme.TextSub,
                TextSize = 13,
                TextXAlignment = Enum.TextXAlignment.Left
            })
            regTheme(TitleLabel, function() TitleLabel.TextColor3 = Theme.TextSub end)

            local BindContainer = createInstance('Frame', {
                Parent = BindFrame,
                AnchorPoint = Vector2.new(1, 0.5),
                Position = UDim2.new(1, -6, 0.5, 0),
                Size = UDim2.new(0, 60, 0, 22),
                BackgroundColor3 = Color3.fromRGB(35, 35, 35)
            })
            createInstance('UICorner', {Parent = BindContainer, CornerRadius = UDim.new(0, 4)})
            regTheme(BindContainer, function() BindContainer.BackgroundColor3 = Theme.MainBG end)
            
            local BindContainerStroke = createInstance('UIStroke', {Parent = BindContainer, Color = Theme.Border})
            regTheme(BindContainerStroke, function() BindContainerStroke.Color = Theme.Border end)

            local BindBtn = createInstance('TextButton', {
                Parent = BindContainer,
                BackgroundTransparency = 1,
                Size = UDim2.new(1, 0, 1, 0),
                Text = currentBind.Name,
                Font = Enum.Font.Gotham,
                TextColor3 = Theme.TextSub,
                TextSize = 11
            })

            SetupTooltip(BindFrame, options.Tip)

            local UpdateBindSize = function()
                local bindName = currentBind and currentBind.Name or 'None'
                BindBtn.Text = bindName
                local textBounds = TextService:GetTextSize(bindName, 11, Enum.Font.Gotham, Vector2.new(1000, 22))
                BindContainer.Size = UDim2.new(0, math.max(textBounds.X + 16, 40), 0, 22)
            end
            UpdateBindSize()

            local isBinding = false
            BindBtn.MouseButton1Click:Connect(function()
                isBinding = true
                BindBtn.Text = '...'
                BindContainer.Size = UDim2.new(0, 40, 0, 22)
            end)

            UserInputService.InputBegan:Connect(function(input, gpe)
                if isBinding and (input.UserInputType == Enum.UserInputType.Keyboard or input.UserInputType == Enum.UserInputType.Gamepad1) then
                    currentBind = input.KeyCode
                    isBinding = false
                    UpdateBindSize()
                    
                    Element.Value = currentBind
                    AkenaLib.Flags[ElementName].Value = currentBind
                    Callback(currentBind)
                end
            end)
            
            function Element:Set(val)
                currentBind = val
                UpdateBindSize()
                Element.Value = currentBind
                AkenaLib.Flags[ElementName].Value = currentBind
                Callback(currentBind)
            end

            return Element
        end

        return setmetatable(Builder, {__index = Builder})
    end

    local HomeBody = MasterContainers['Home']
    local Sidebar = createInstance('ScrollingFrame', {
        Parent = HomeBody,
        BackgroundTransparency = 1,
        Size = UDim2.new(0, 160, 1, 0),
        BorderSizePixel = 0,
        ScrollBarThickness = 0,
        AutomaticCanvasSize = Enum.AutomaticSize.Y,
        CanvasSize = UDim2.new(0, 0, 0, 0)
    })

    createInstance('UIListLayout', {
        Parent = Sidebar,
        SortOrder = Enum.SortOrder.LayoutOrder,
        Padding = UDim.new(0, 4)
    })
    
    createInstance('UIPadding', {
        Parent = Sidebar,
        PaddingTop = UDim.new(0, 10),
        PaddingLeft = UDim.new(0, 8),
        PaddingRight = UDim.new(0, 8)
    })

    local ContentContainer = createInstance('Frame', {
        Parent = HomeBody,
        BackgroundTransparency = 1,
        Position = UDim2.new(0, 160, 0, 0),
        Size = UDim2.new(1, -160, 1, 0)
    })

    WindowObj.CreateTab = function(self, options)
        local TabName = options.Name or 'Tab'
        local TabIconId = options.Icon or 'rbxassetid://6034502844'

        local TabBtn = createInstance('ImageButton', {
            Parent = Sidebar,
            BackgroundColor3 = Color3.fromRGB(255, 255, 255),
            BackgroundTransparency = 1,
            Size = UDim2.new(1, 0, 0, 38),
            AutoButtonColor = false,
            Image = ''
        })
        createInstance('UICorner', {Parent = TabBtn, CornerRadius = UDim.new(0, 4)})

        local TabGradient = createInstance('UIGradient', {
            Parent = TabBtn,
            Color = ColorSequence.new(Theme.Accent),
            Offset = Vector2.new(-1, 0),
            Transparency = NumberSequence.new({
                NumberSequenceKeypoint.new(0, 0.86),
                NumberSequenceKeypoint.new(0.6, 1),
                NumberSequenceKeypoint.new(1, 1)
            })
        })
        regTheme(TabGradient, function()
            TabGradient.Color = ColorSequence.new(Theme.Accent)
        end)

        local IconImg = createInstance('ImageLabel', {
            Parent = TabBtn,
            BackgroundTransparency = 1,
            Position = UDim2.new(0, 12, 0.5, -9),
            Size = UDim2.new(0, 18, 0, 18),
            Image = TabIconId,
            ImageColor3 = Theme.TextSub
        })

        local TextLabel = createInstance('TextLabel', {
            Parent = TabBtn,
            BackgroundTransparency = 1,
            Position = UDim2.new(0, 40, 0, 0),
            Size = UDim2.new(1, -40, 1, 0),
            Font = Enum.Font.GothamMedium,
            Text = TabName,
            TextColor3 = Theme.TextSub,
            TextSize = 13,
            TextXAlignment = Enum.TextXAlignment.Left
        })

        TabBtn.MouseEnter:Connect(function()
            if WindowObj.CurrentTab ~= TabName then
                TweenService:Create(TextLabel, TweenInfo.new(0.2), {TextColor3 = Color3.fromRGB(210, 210, 210)}):Play()
                TweenService:Create(IconImg, TweenInfo.new(0.2), {ImageColor3 = Color3.fromRGB(210, 210, 210)}):Play()
            end
        end)
        TabBtn.MouseLeave:Connect(function()
            if WindowObj.CurrentTab ~= TabName then
                TweenService:Create(TextLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextSub}):Play()
                TweenService:Create(IconImg, TweenInfo.new(0.2), {ImageColor3 = Theme.TextSub}):Play()
            end
        end)

        local PageGroup = createInstance('CanvasGroup', {
            Parent = ContentContainer,
            Size = UDim2.new(1, 0, 1, 0),
            Position = UDim2.new(0, 50, 0, 0),
            BackgroundTransparency = 1,
            GroupTransparency = 1,
            BorderSizePixel = 0,
            Visible = false
        })

        local Page = createInstance('ScrollingFrame', {
            Parent = PageGroup,
            BackgroundTransparency = 1,
            Size = UDim2.new(1, 0, 1, 0),
            ScrollBarThickness = 2,
            ScrollBarImageColor3 = Theme.Border,
            BorderSizePixel = 0,
            AutomaticCanvasSize = Enum.AutomaticSize.Y,
            CanvasSize = UDim2.new(0, 0, 0, 0)
        })
        regTheme(Page, function() Page.ScrollBarImageColor3 = Theme.Border end)
        
        createInstance('UIPadding', {
            Parent = Page,
            PaddingTop = UDim.new(0, 15),
            PaddingLeft = UDim.new(0, 20),
            PaddingRight = UDim.new(0, 20)
        })

        createInstance('UIListLayout', {
            Parent = Page,
            SortOrder = Enum.SortOrder.LayoutOrder,
            Padding = UDim.new(0, 8)
        })

        local TabObj = { Name = TabName, Page = Page, Select = nil }
        local Builder = CreateElementBuilder(Page, TabObj)

        TabObj.Select = function()
            if WindowObj.CurrentTab == TabObj.Name then return end
            if WindowObj.CurrentTab then 
                WindowObj.CurrentTab.Unselect() 
            end
            WindowObj.CurrentTab = TabObj
            
            PageGroup.Visible = true
            PageGroup.Position = UDim2.new(0, 50, 0, 0)
            PageGroup.GroupTransparency = 1
            TweenService:Create(PageGroup, TweenInfo.new(0.65, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, 0, 0, 0), GroupTransparency = 0}):Play()
            
            TweenService:Create(TabBtn, TweenInfo.new(0.2), {BackgroundTransparency = 0}):Play()
            TweenService:Create(TabGradient, TweenInfo.new(0.45, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Offset = Vector2.new(0, 0)}):Play()
            TweenService:Create(TextLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextMain}):Play()
            TweenService:Create(IconImg, TweenInfo.new(0.2), {ImageColor3 = Theme.TextMain}):Play()
        end

        TabObj.Unselect = function()
            TweenService:Create(PageGroup, TweenInfo.new(0.65, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, -50, 0, 0), GroupTransparency = 1}):Play()
            task.delay(0.65, function() if WindowObj.CurrentTab ~= TabObj then PageGroup.Visible = false end end)

            TweenService:Create(TabGradient, TweenInfo.new(0.45, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Offset = Vector2.new(-1, 0)}):Play()
            TweenService:Create(TabBtn, TweenInfo.new(0.2), {BackgroundTransparency = 1}):Play()
            TweenService:Create(TextLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextSub}):Play()
            TweenService:Create(IconImg, TweenInfo.new(0.2), {ImageColor3 = Theme.TextSub}):Play()
        end

        TabBtn.MouseButton1Click:Connect(TabObj.Select)

        if #WindowObj.Tabs == 0 then TabObj.Select() end
        table.insert(WindowObj.Tabs, TabObj)

        return setmetatable(TabObj, {__index = Builder})
    end

    local MakeSubTabElements = function(TabName)
        local parentGrp = MasterContainers[TabName]
        local Page = createInstance('ScrollingFrame', {
            Parent = parentGrp,
            BackgroundTransparency = 1,
            Size = UDim2.new(1, 0, 1, 0),
            ScrollBarThickness = 2,
            ScrollBarImageColor3 = Theme.Border,
            BorderSizePixel = 0,
            AutomaticCanvasSize = Enum.AutomaticSize.Y,
            CanvasSize = UDim2.new(0, 0, 0, 0)
        })
        createInstance('UIPadding', {
            Parent = Page,
            PaddingTop = UDim.new(0, 15),
            PaddingLeft = UDim.new(0, 20),
            PaddingRight = UDim.new(0, 20)
        })
        createInstance('UIListLayout', {
            Parent = Page,
            SortOrder = Enum.SortOrder.LayoutOrder,
            Padding = UDim.new(0, 8)
        })
        regTheme(Page, function() Page.ScrollBarImageColor3 = Theme.Border end)
        return CreateElementBuilder(Page, {Name = TabName, Page = Page, Select = function()
            if activeSubTab ~= TabName then
                local btn = SubTabs:FindFirstChild(TabName .. 'Tab')
                if btn then
                    local subChildren = SubTabs:GetChildren()
                    for i = 1, #subChildren do
                        local child = subChildren[i]
                        if child:IsA('ImageButton') and child.Name ~= TabName .. 'Tab' then
                            TweenService:Create(child.TextLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextSub}):Play()
                            TweenService:Create(child.Frame, TweenInfo.new(0.2), {Size = UDim2.new(0, 0, 0, 2), BackgroundTransparency = 1}):Play()
                            local oc = MasterContainers[child.Name:gsub('Tab', '')]
                            if oc then
                                TweenService:Create(oc, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.In), {Position = UDim2.new(0, 0, 0, -15), GroupTransparency = 1}):Play()
                                task.delay(0.25, function() oc.Visible = false end)
                            end
                        end
                    end
                    activeSubTab = TabName
                    TweenService:Create(btn.TextLabel, TweenInfo.new(0.2), {TextColor3 = Theme.TextMain}):Play()
                    TweenService:Create(btn.Frame, TweenInfo.new(0.2), {Size = UDim2.new(1, 0, 0, 2), BackgroundTransparency = 0}):Play()
                    local nc = MasterContainers[TabName]
                    if nc then
                        nc.Visible = true
                        nc.Position = UDim2.new(0, 0, 0, 15)
                        nc.GroupTransparency = 1
                        TweenService:Create(nc, TweenInfo.new(0.4, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Position = UDim2.new(0, 0, 0, 0), GroupTransparency = 0}):Play()
                    end
                end
            end
        end})
    end

    WindowObj.UISettings = MakeSubTabElements('UI Settings')
    
    WindowObj.UISettings:CreateKeybind({
        Name = 'Menu Visible Keybind',
        Default = MenuKeybind,
        Callback = function(key) MenuKeybind = key end
    })
    
    local themeNamesList = {}
    for name, _ in pairs(Themes) do
        table.insert(themeNamesList, name)
    end
    table.sort(themeNamesList)

    WindowObj.UISettings:CreateDropdown({
        Name = 'Select UI Theme',
        Options = themeNamesList,
        Default = defaultTheme,
        Callback = function(selectedTheme)
            ApplySelectedTheme(selectedTheme)
        end
    })
    
    local AccentColorElement
    AccentColorElement = WindowObj.UISettings:CreateColorpicker({
        Name = 'Accent Color',
        Default = Theme.Accent,
        Callback = function(color) 
            if not AkenaLib.RainbowAccent then
                UpdateThemeAccent(color) 
            end
        end
    })

    WindowObj.UISettings:CreateToggle({
        Name = 'Rainbow Accent',
        Default = false,
        Callback = function(val)
            AkenaLib.RainbowAccent = val
            if not val and AccentColorElement then
                UpdateThemeAccent(AccentColorElement.Value)
            end
        end
    })

    WindowObj.UISettings:CreateSlider({
        Name = 'Rainbow Speed',
        Min = 1,
        Max = 20,
        Default = 5,
        Increment = 1,
        Suffix = '',
        Callback = function(val)
            AkenaLib.RainbowSpeed = val
        end
    })

    WindowObj.UISettings:CreateButton({
        Name = 'Randomize Theme',
        Callback = function()
            local baseHue = math.random()
            local bgSaturation = math.random() * 0.2
            local bgValue = math.random() * 0.15 + 0.05
            
            Theme.MainBG = Color3.fromHSV(baseHue, bgSaturation, bgValue)
            Theme.SidebarBG = Color3.fromHSV(baseHue, bgSaturation, math.clamp(bgValue + 0.02, 0, 1))
            Theme.TopbarBG = Color3.fromHSV(baseHue, bgSaturation, math.clamp(bgValue - 0.02, 0, 1))
            Theme.ElementBG = Color3.fromHSV(baseHue, bgSaturation, math.clamp(bgValue + 0.05, 0, 1))
            Theme.Border = Color3.fromHSV(baseHue, bgSaturation, math.clamp(bgValue + 0.1, 0, 1))
            Theme.DropdownListBG = Theme.ElementBG
            Theme.DropdownListStroke = Theme.Border
            
            local acH = (baseHue + math.random() * 0.5) % 1
            Theme.Accent = Color3.fromHSV(acH, 0.8, 0.9)
            
            Theme.TextMain = Color3.fromRGB(240, 240, 240)
            Theme.TextSub = Color3.fromRGB(160, 160, 160)

            local alive = {}
            for i = 1, #AkenaLib.ThemeConnections do
                local func = AkenaLib.ThemeConnections[i]
                if type(func) == 'function' then
                    local s, res = pcall(func)
                    if s and res ~= false then 
                        table.insert(alive, func) 
                    end
                end
            end
            AkenaLib.ThemeConnections = alive
        end
    })

    WindowObj.UISettings:CreateToggle({
        Name = 'Notifications & Tooltips',
        Default = true,
        Callback = function(val) 
            AkenaLib.ShowNotifications = val 
            AkenaLib.ShowTooltips = val 
        end
    })

    WindowObj.UISettings:CreateSlider({
        Name = 'Window Scale',
        Min = 50,
        Max = 150,
        Default = 100,
        Increment = 5,
        Suffix = '%',
        Callback = function(val) WindowObj:UpdateScale(val / 100) end
    })

    WindowObj.Configs = MakeSubTabElements('Configs')
    local ConfigName = 'default'
    local ConfigFolder = 'akena/' .. tostring(game.GameId)
    local SecureFolder = function()
        if makefolder then
            if not isfolder('akena') then makefolder('akena') end
            if not isfolder(ConfigFolder) then makefolder(ConfigFolder) end
        end
    end
    local RefreshConfigs = function(dropdownObj)
        if not listfiles then return end
        SecureFolder()
        local list = {}
        local success, files = pcall(function() return listfiles(ConfigFolder) end)
        if success and type(files) == 'table' then
            for i = 1, #files do
                local file = files[i]
                if type(file) == 'string' then
                    local match = file:match('([^/\\\\]+)%.json$')
                    if match then table.insert(list, match) end
                elseif type(file) == 'table' then
                    local path = file.Path or file.path or file.Name or file.name or tostring(file)
                    if type(path) == 'string' then
                        local match = path:match('([^/\\\\]+)%.json$')
                        if match then table.insert(list, match) end
                    end
                end
            end
        end
        dropdownObj:Refresh(list)
    end

    local CfgTextBox = WindowObj.Configs:CreateTextbox({
        Name = 'Config Name',
        UseLetter = true,
        UseNumber = true,
        Callback = function(txt) ConfigName = txt end
    })

    local AutoloadTog
    local isAutoload = (readfile and isfile('akena_autoload.txt') and readfile('akena_autoload.txt') == ConfigName) or false
    
    AutoloadTog = WindowObj.Configs:CreateToggle({
        Name = 'Autoload',
        Default = isAutoload,
        Callback = function(val)
            if writefile then
                SecureFolder()
                if val then
                    writefile('akena_autoload.txt', ConfigName)
                else
                    if isfile('akena_autoload.txt') then
                        delfile('akena_autoload.txt')
                    end
                end
            end
        end
    })

    local ConfigDrop
    WindowObj.Configs:CreateButton({
        Name = 'Save Config',
        Callback = function()
            if writefile then
                SecureFolder()
                local data = {}
                for k,v in pairs(AkenaLib.Flags) do 
                    data[k] = SerializeValue(v.Value) 
                end
                writefile(ConfigFolder .. '/' .. ConfigName .. '.json', HttpService:JSONEncode(data))
                if ConfigDrop then RefreshConfigs(ConfigDrop) end
            end
        end
    })

    WindowObj.Configs:CreateButton({
        Name = 'Load Config',
        Callback = function()
            if readfile and isfile(ConfigFolder .. '/' .. ConfigName .. '.json') then
                local success, data = pcall(function()
                    return HttpService:JSONDecode(readfile(ConfigFolder .. '/' .. ConfigName .. '.json'))
                end)
                if success and type(data) == 'table' then
                    for k,v in pairs(data) do
                        local flagElement = AkenaLib.Flags[k]
                        if flagElement then 
                            local decodedVal = DeserializeValue(v)
                            if decodedVal ~= nil then
                                flagElement:Set(decodedVal)
                            end
                        end
                    end
                end
            end
        end
    })

    ConfigDrop = WindowObj.Configs:CreateDropdown({
        Name = 'View Configs',
        Options = {},
        Callback = function(sel) 
            ConfigName = sel 
            if AutoloadTog then
                local activeAuto = (readfile and isfile('akena_autoload.txt') and readfile('akena_autoload.txt') == ConfigName) or false
                AutoloadTog:Set(activeAuto)
            end
        end
    })
    RefreshConfigs(ConfigDrop)

    WindowObj.Configs:CreateButton({
        Name = 'Delete Config',
        Callback = function()
            if delfile and isfile(ConfigFolder .. '/' .. ConfigName .. '.json') then
                delfile(ConfigFolder .. '/' .. ConfigName .. '.json')
                if ConfigDrop then RefreshConfigs(ConfigDrop) end
            end
        end
    })

    ApplySelectedTheme(defaultTheme)

    task.spawn(function()
        if readfile and isfile('akena_autoload.txt') then
            local autoCfg = readfile('akena_autoload.txt')
            local filePath = ConfigFolder .. '/' .. autoCfg .. '.json'
            if isfile(filePath) then
                local success, data = pcall(function()
                    return HttpService:JSONDecode(readfile(filePath))
                end)
                if success and type(data) == 'table' then
                    task.wait(0.5)
                    for k,v in pairs(data) do
                        local flagElement = AkenaLib.Flags[k]
                        if flagElement then 
                            local decodedVal = DeserializeValue(v)
                            if decodedVal ~= nil then
                                flagElement:Set(decodedVal)
                            end
                        end
                    end
                end
            end
        end
    end)

    local connection
    connection = RunService.RenderStepped:Connect(function()
        local success, hasParent = pcall(function() return ScreenGui and ScreenGui.Parent end)
        if not success or not hasParent then
            if connection then connection:Disconnect() end
            return
        end
    end)

    return WindowObj
end

local Window = AkenaLib:CreateWindow({
    Title = 'na',
    Prefix = 'Ake',
    Theme = 'Minimal White'
})

local ThrowingTab = Window:CreateTab({ Name = 'QB Aimbot', Icon = 'rbxassetid://6034684949' })

enableQbAimbot = ThrowingTab:CreateToggle({
    Name = 'Enable QB Aimbot',
    Default = false,
    Tip = 'Automatically aims passes at the best target for more accurate throws.',
})

throwAimbot = ThrowingTab:CreateToggle({
    Name = 'Throw To Mouse Aimbot',
    Default = false,
    Tip = 'Automatically aims passes toward your mouse position.',
})

autoChooseWr = ThrowingTab:CreateToggle({
    Name = 'Auto Choose Open Reciever',
    Default = false,
    Tip = 'Automatically selects the most open receiver for each throw.',
})

autoSelectThrowMode = ThrowingTab:CreateToggle({
    Name = 'Auto Select Throw Type',
    Default = false,
    Tip = 'Automatically chooses the best throw type for each pass.',
})

autoPower = ThrowingTab:CreateToggle({
    Name = 'Auto Power',
    Default = false,
    Tip = 'Automatically sets the optimal throw power.',
})

autoAngle = ThrowingTab:CreateToggle({
    Name = 'Auto Angle',
    Default = false,
    Tip = 'Automatically adjusts throw angle for better accuracy.',
})

highPowerOnly = ThrowingTab:CreateToggle({
    Name = 'High Power Only',
    Default = false,
    Tip = 'Only uses high-power throws when passing.',
})

antiDB = ThrowingTab:CreateToggle({
    Name = 'Anti DB',
    Default = false,
    Tip = 'Avoids throws that defenders can easily intercept.',
})

antiDBThreshold = ThrowingTab:CreateSlider({
    Name = 'Anti DB Threshold',
    Min = 0,
    Max = 15,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets how aggressively defender coverage is avoided.',
})

antiOOB = ThrowingTab:CreateToggle({
    Name = 'Anti OOB',
    Default = false,
    Tip = 'Prevents throws that may lead receivers out of bounds.',
})

antiOOBThreshold = ThrowingTab:CreateSlider({
    Name = 'Anti OOB Threshold',
    Min = 0,
    Max = 15,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets how close targets can be to the sideline.',
})

throwLeadOffset = ThrowingTab:CreateSlider({
    Name = 'Throw Lead Offset',
    Min = -10,
    Max = 10,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Adjusts how far ahead passes are led.',
})

throwHeightOffset = ThrowingTab:CreateSlider({
    Name = 'Throw Height Offset',
    Min = -10,
    Max = 10,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Adjusts the height of targeted throws.',
})

autoJuke = ThrowingTab:CreateToggle({
    Name = 'Auto Juke Rusher',
    Default = false,
    Tip = 'Automatically jukes nearby rushers before throwing.',
})

hideCards = ThrowingTab:CreateToggle({
    Name = 'Hide QB Aimbot Cards',
    Default = false,
    Tip = 'Hides QB Aimbot visual cards from the screen.',
})

autoChangePowerUI = ThrowingTab:CreateToggle({
    Name = 'Auto Change Power UI',
    Default = false,
    Tip = 'Automatically updates the power UI to match throws.',
})

autoJumpWhenThrow = ThrowingTab:CreateToggle({
    Name = 'Auto Jump Before Throw',
    Default = false,
    Tip = 'Automatically jumps before releasing the ball.',
})

autoThrowAfterSack = ThrowingTab:CreateToggle({
    Name = 'Auto Throw Before Getting Sacked',
    Default = false,
    Tip = 'Automatically throws the ball when a sack is imminent.',
})

dimeKeybind = ThrowingTab:CreateKeybind({
    Name = 'Dime Mode Keybind',
    Default = Enum.KeyCode.One,
    Tip = 'Switches to Dime throw mode.',
})

magKeybind = ThrowingTab:CreateKeybind({
    Name = 'Mag Mode Keybind',
    Default = Enum.KeyCode.Two,
    Tip = 'Switches to Mag throw mode.',
})

diveKeybind = ThrowingTab:CreateKeybind({
    Name = 'Dive Mode Keybind',
    Default = Enum.KeyCode.Three,
    Tip = 'Switches to Dive throw mode.',
})

jumpKeybind = ThrowingTab:CreateKeybind({
    Name = 'Jump Mode Keybind',
    Default = Enum.KeyCode.Four,
    Tip = 'Switches to Jump throw mode.',
})

bulletKeybind = ThrowingTab:CreateKeybind({
    Name = 'Bullet Mode Keybind',
    Default = Enum.KeyCode.Five,
    Tip = 'Switches to Bullet throw mode.',
})

throwBallAwayKeybind = ThrowingTab:CreateKeybind({
    Name = 'Throw Ball Away Keybind',
    Default = Enum.KeyCode.T,
    Tip = 'Instantly throws the ball away.',
})

increaseAngleKeybind = ThrowingTab:CreateKeybind({
    Name = 'Increase Angle Keybind',
    Default = Enum.KeyCode.R,
    Tip = 'Increases the current throw angle.',
})

decreaseAngleKeybind = ThrowingTab:CreateKeybind({
    Name = 'Decrease Angle Keybind',
    Default = Enum.KeyCode.F,
    Tip = 'Decreases the current throw angle.',
})

lockKeybind = ThrowingTab:CreateKeybind({
    Name = 'Lock To Target Keybind',
    Default = Enum.KeyCode.Z,
    Tip = 'Locks passes onto the current target.',
})

local players = game:GetService('Players')
local replicatedStorage = game:GetService('ReplicatedStorage')
local tweenService = game:GetService('TweenService')
local userInputService = game:GetService('UserInputService')
local runService = game:GetService('RunService')
local stats = game:GetService('Stats')
local camera = workspace.CurrentCamera
local lp = players.LocalPlayer
if not lp then
    players:GetPropertyChangedSignal('LocalPlayer'):Wait()
    lp = players.LocalPlayer
end
local mouse = lp:GetMouse()

local isPractice = (game.PlaceId == 81310542478972)
if isPractice then
    autoJuke.Value = false
end

local targetLocked = false
local lockedTarget = nil

local RouteData = {}
local HUDCards = {}
local rusherHighlights = {}
local numCards = 0

local leadDime = 8.5
local leadMag = 8.6
local leadDive = 8.5
local leadJump = 8.4
local leadBullet = 2.5 

local yLeadDime = 1.2
local yLeadMag = 1.0
local yLeadDive = 1.5
local yLeadJump = 2.0
local yLeadBullet = -0.8

local ModeOrder = {'Bullet', 'Dime', 'Dive', 'Jump', 'Mag'}

local QBKeybinds = {
    [dimeKeybind.Value] = 'Dime',
    [magKeybind.Value] = 'Mag',
    [diveKeybind.Value] = 'Dive',
    [jumpKeybind.Value] = 'Jump',
    [bulletKeybind.Value] = 'Bullet'
}

local customHeight = { Value = 0 }

local target = nil
local lastValidTarget = nil
local targetLeadPos = nil
local highlight = nil
local direction = Vector3.new(0, 1, 0)
local power = 60
local angle = 45
local airtime = 0
local isThrowing = false
local isThrowingAway = false
local firedRemote = false
local modeIndex = 1
local smoothedJukeDir = Vector3.zero

local lockedMousePos = nil

local LockToggleBtn = nil
local LockedLabel = nil

local attach0 = Instance.new('Attachment', workspace.Terrain)
local attach1 = Instance.new('Attachment', workspace.Terrain)

local beam = Instance.new('Beam')
beam.Attachment0 = attach0
beam.Attachment1 = attach1
beam.Segments = 7500
beam.Width0 = 1
beam.Width1 = 1
beam.FaceCamera = true
beam.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255))
beam.Transparency = NumberSequence.new({
    NumberSequenceKeypoint.new(0, 1),
    NumberSequenceKeypoint.new(0.01, 0),
    NumberSequenceKeypoint.new(1, 0)
})
beam.Enabled = true
beam.Parent = workspace.Terrain

local posPart = Instance.new('Part', workspace.Terrain)
posPart.Anchored = true
posPart.CanCollide = false
posPart.CastShadow = false
posPart.Size = Vector3.new(3, 3, 3)
posPart.Shape = Enum.PartType.Ball
posPart.Color = Color3.fromRGB(0, 0, 0)

local hudFolder = nil
pcall(function()
    hudFolder = (gethui and gethui()) or game:GetService('CoreGui')
end)
if not hudFolder or (hudFolder.Name == 'CoreGui' and not pcall(function() Instance.new('Folder', hudFolder):Destroy() end)) then
    hudFolder = lp:WaitForChild('PlayerGui', 10)
end

local sg = Instance.new('ScreenGui')
sg.ResetOnSpawn = false
sg.Parent = hudFolder
sg.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

local container = Instance.new('CanvasGroup')
container.Size = UDim2.new(1, 0, 0, 100)
container.Position = UDim2.new(0.5, 0, 0.05, 0)
container.AnchorPoint = Vector2.new(0.5, 0)
container.BackgroundTransparency = 1
container.GroupTransparency = 1
container.Visible = true
container.Parent = sg

local hudVisible = false
local updateHUDVisibility = function(show)
    if show and not hudVisible then
        hudVisible = true
        tweenService:Create(container, TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {GroupTransparency = 0}):Play()
    elseif not show and hudVisible then
        hudVisible = false
        tweenService:Create(container, TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {GroupTransparency = 1}):Play()
    end
end

local containerScale = Instance.new('UIScale', container)

local updateScale = function()
    local vp = camera.ViewportSize
    local scale = (vp.X / 1100)
    containerScale.Scale = math.clamp(scale, 0.5, 1.2)
end

camera:GetPropertyChangedSignal('ViewportSize'):Connect(updateScale)
updateScale()

local layout = Instance.new('UIListLayout')
layout.FillDirection = Enum.FillDirection.Horizontal
layout.HorizontalAlignment = Enum.HorizontalAlignment.Center
layout.VerticalAlignment = Enum.VerticalAlignment.Center
layout.SortOrder = Enum.SortOrder.LayoutOrder
layout.Padding = UDim.new(0, 10)
layout.Parent = container

local assignFont = function(instance, font)
    pcall(function()
        instance.Font = font
    end)
end

local createCard = function(titleTxt)
    local card = Instance.new('Frame')
    card.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    card.BackgroundTransparency = 0
    card.BorderSizePixel = 0
    
    local gradient = Instance.new('UIGradient')
    gradient.Color = ColorSequence.new({
        ColorSequenceKeypoint.new(0, Color3.fromRGB(45, 45, 50)),
        ColorSequenceKeypoint.new(1, Color3.fromRGB(15, 15, 18))
    })
    gradient.Rotation = 90
    gradient.Parent = card
    
    if titleTxt == 'Throw Type' then
        card.Size = UDim2.new(0, 110, 0, 80)
    else
        card.Size = UDim2.new(0, 95, 0, 80)
    end
    
    card.LayoutOrder = numCards
    card.Parent = container

    local corner = Instance.new('UICorner', card)
    corner.CornerRadius = UDim.new(0, 8)

    local stroke = Instance.new('UIStroke', card)
    stroke.Color = Color3.fromRGB(80, 80, 85)
    stroke.Thickness = 1.000

    local padding = Instance.new('UIPadding', card)
    padding.PaddingTop = UDim.new(0, 5)
    padding.PaddingBottom = UDim.new(0, 5)

    local title = Instance.new('TextLabel')
    title.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    title.BackgroundTransparency = 1.000
    title.BorderSizePixel = 0
    title.Position = UDim2.new(0, 0, 0.70, 0)
    title.Size = UDim2.new(1, 0, 0, 15)
    assignFont(title, Enum.Font.GothamBold)
    title.Text = titleTxt
    title.TextColor3 = Color3.fromRGB(255, 255, 255)
    title.TextScaled = true
    title.Parent = card

    local valBtn = Instance.new('TextButton')
    valBtn.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    valBtn.BackgroundTransparency = 1.000
    valBtn.BorderSizePixel = 0
    valBtn.Position = UDim2.new(0, 0, 0.15, 0)
    valBtn.Size = UDim2.new(1, 0, 0.5, 0)
    assignFont(valBtn, Enum.Font.GothamBold)
    valBtn.Text = '-'
    valBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
    valBtn.TextScaled = true
    valBtn.AutoButtonColor = false
    valBtn.Parent = card

    if titleTxt == 'Throw Type' then
        local uiScale = Instance.new('UIScale', card)
        valBtn.MouseButton1Down:Connect(function()
            local c = lp.Character
            if not c or not c:FindFirstChild('Football') then return end
            tweenService:Create(uiScale, TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Scale = 0.9}):Play()
        end)
        valBtn.MouseButton1Up:Connect(function()
            local c = lp.Character
            if not c or not c:FindFirstChild('Football') then return end
            tweenService:Create(uiScale, TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Scale = 1}):Play()
            modeIndex = modeIndex + 1
            if modeIndex > #ModeOrder then modeIndex = 1 end
        end)
    end

    if titleTxt == 'Player' then
        local lockedLbl = Instance.new('TextLabel')
        lockedLbl.Size = UDim2.new(1, 0, 0.25, 0)
        lockedLbl.Position = UDim2.new(0, 0, 0.05, 0)
        lockedLbl.BackgroundTransparency = 1
        lockedLbl.Text = 'LOCKED'
        lockedLbl.TextColor3 = Color3.fromRGB(255, 50, 50)
        assignFont(lockedLbl, Enum.Font.GothamBold)
        lockedLbl.TextSize = 12
        lockedLbl.Visible = false
        lockedLbl.ZIndex = 2
        lockedLbl.Parent = card

        LockedLabel = lockedLbl

        local lockOverlay = Instance.new('TextButton')
        lockOverlay.Size = UDim2.new(1, 0, 1, 0)
        lockOverlay.BackgroundTransparency = 1
        lockOverlay.Text = ''
        lockOverlay.ZIndex = 5
        lockOverlay.Parent = card

        lockOverlay.MouseButton1Click:Connect(function()
            local c = lp.Character
            if not c or not c:FindFirstChild('Football') then return end
            if target or targetLocked then
                targetLocked = not targetLocked
                if targetLocked then
                    lockedTarget = target
                    if LockedLabel then LockedLabel.Visible = true end
                else
                    lockedTarget = nil
                    if LockedLabel then LockedLabel.Visible = false end
                end
            end
        end)
        
        LockToggleBtn = valBtn
    end

    HUDCards[titleTxt] = valBtn
    numCards = numCards + 1
end

createCard('Angle')
createCard('Throw Type')
createCard('Player')
createCard('Airtime')
createCard('Power')

local getActiveBots = function()
    local bots = {}
    local npcwr = workspace:FindFirstChild('npcwr')
    if npcwr then
        local a = npcwr:FindFirstChild('a')
        if a then
            local bot1 = a:FindFirstChild('bot 1')
            if bot1 and bot1:IsA('Model') then table.insert(bots, bot1) end
        end
        local b = npcwr:FindFirstChild('b')
        if b then
            local bot3 = b:FindFirstChild('bot 3')
            if bot3 and bot3:IsA('Model') then table.insert(bots, bot3) end
        end
    end
    return bots
end

local performThrow = function()
    if not enableQbAimbot.Value then return end

    local character = lp.Character
    if not character then return end

    local football = character:FindFirstChildOfClass('Tool')
    if not football then return end

    local handle = football:FindFirstChild('Handle')
    if not handle then return end

    local remote = handle:FindFirstChild('RemoteEvent')
    if not remote then return end

    local head = character:FindFirstChild('Head')
    if not head then return end

    local root = character:FindFirstChild('HumanoidRootPart')
    if not root then return end

    local finalDirection = direction or Vector3.new(0, 1, 0)

    if isPractice then
        local arg = 'Clicked'
        local arg1 = head.Position
        local arg2 = head.Position + finalDirection * 10000
        local arg3 = tonumber(power) or 0
        remote:FireServer(arg, arg1, arg2, arg3)
    else
        local arg = 'Clicked'
        local arg1 = (root.CFrame * CFrame.new(0, 1.5, 0)).Position + Vector3.new(70000000)
        local arg2 = head.Position + finalDirection * 10000
        local arg3 = tonumber(power) or 0
        remote:FireServer(arg, arg1, arg2, arg3, 1)
    end
end

local findRoute = function(character)
    if not character then return 'stationary', Vector3.zero end
    local isPlayer = players:GetPlayerFromCharacter(character)
    local humanoid = character:FindFirstChild('Humanoid')
    local targetHRP = character:FindFirstChild('HumanoidRootPart')
    local qbChar = lp.Character
    local qbHRP = qbChar and qbChar:FindFirstChild('HumanoidRootPart')
    
    if not humanoid or not targetHRP or not qbHRP then 
        return 'stationary', Vector3.zero 
    end
    
    local moveDirection = Vector3.zero
    if isPlayer then
        moveDirection = humanoid.MoveDirection
    else
        local wtpDiff = humanoid.WalkToPoint - targetHRP.Position
        moveDirection = wtpDiff.Magnitude > 0.01 and wtpDiff.Unit or Vector3.zero
    end
    
    local toWR = targetHRP.Position - qbHRP.Position
    local distance = tonumber(toWR.Magnitude) or 0

    local toWRDir = Vector3.new(toWR.X, 0, toWR.Z)
    if toWRDir.Magnitude > 0.01 then
        toWRDir = toWRDir.Unit
    else
        toWRDir = Vector3.new(0, 0, 1)
    end

    local mdFlat = Vector3.new(moveDirection.X, 0, moveDirection.Z)
    if mdFlat.Magnitude < 0.01 then
        return 'stationary', moveDirection
    end
    mdFlat = mdFlat.Unit

    local dot = tonumber(mdFlat:Dot(toWRDir)) or 0

    if dot > 0.75 then
        return 'go/fade', moveDirection
    elseif dot >= 0.25 and dot <= 0.75 then
        if distance <= 120 then return 'slant', moveDirection
        elseif distance <= 160 then return 'seam', moveDirection
        else return 'post/corner', moveDirection end
    elseif dot > -0.25 and dot < 0.25 then
        if distance <= 60 then return 'drag', moveDirection
        elseif distance <= 130 then return 'in/out', moveDirection
        else return 'flat', moveDirection end
    else
        if distance <= 50 then return 'hitch', moveDirection
        else return 'curl/comeback', moveDirection end
    end
end

local isWROpen = function(wrChar)
    if not wrChar then return false end
    local hrp = wrChar:FindFirstChild('HumanoidRootPart')
    if not hrp then return false end

    local isCovered = false
    local _, moveDir = findRoute(wrChar)
    
    local teamCount = 0
    pcall(function() teamCount = tonumber(#game:GetService('Teams'):GetTeams()) or 0 end)
    
    local checkDB = function(dbHRP)
        local toDB = dbHRP.Position - hrp.Position
        local dist = tonumber(toDB.Magnitude) or 0
        if dist < 5 then
            local routeDirXZ = Vector3.new(moveDir.X, 0, moveDir.Z)
            if (tonumber(routeDirXZ.Magnitude) or 0) > 0.01 then
                routeDirXZ = routeDirXZ.Unit
                local dot = tonumber(toDB.Unit:Dot(routeDirXZ)) or 0
                if dot > -0.7 then 
                    return true
                end
            else
                return true
            end
        end
        return false
    end

    local checkPR = function(dbHRP)
        local qbChar = lp.Character
        if not qbChar then return false end
        local qbHRP = qbChar:FindFirstChild('HumanoidRootPart')
        if not qbHRP then return false end
        
        local toPR = dbHRP.Position - qbHRP.Position
        local toWR = hrp.Position - qbHRP.Position
        local wrDist = tonumber(toWR.Magnitude) or 0
        local wrDir = toWR.Unit
        
        local proj = tonumber(toPR:Dot(wrDir)) or 0
        if proj > 2 and proj < (wrDist * 0.6) then
            local distToLine = tonumber((toPR - (wrDir * proj)).Magnitude) or 0
            if distToLine < 5.5 then
                return true
            end
        end
        return false
    end

    local plrs = players:GetPlayers()
    for i = 1, #plrs do
        local plr = plrs[i]
        if plr ~= lp and plr.Character then
            local isEnemy = true
            if teamCount > 1 and lp.Team ~= nil and plr.Team ~= nil and lp.Team == plr.Team then
                isEnemy = false
            end
            if isEnemy then
                local dbHRP = plr.Character:FindFirstChild('HumanoidRootPart')
                if dbHRP and (checkDB(dbHRP) or checkPR(dbHRP)) then
                    isCovered = true
                    break
                end
            end
        end
    end

    if not isCovered then
        local bots = getActiveBots()
        for i = 1, #bots do
            local bot = bots[i]
            if bot ~= wrChar then
                local dbHRP = bot:FindFirstChild('HumanoidRootPart')
                if dbHRP and (checkDB(dbHRP) or checkPR(dbHRP)) then
                    isCovered = true
                    break
                end
            end
        end
    end

    return not isCovered
end

local getTarget = function()
    if isThrowing and target then return target end
    
    if targetLocked and lockedTarget and lockedTarget:FindFirstChild('HumanoidRootPart') then
        return lockedTarget
    elseif targetLocked then
        targetLocked = false
        lockedTarget = nil
    end

    local potentialTargets = {}
    local teamCount = 0
    pcall(function() teamCount = tonumber(#game:GetService('Teams'):GetTeams()) or 0 end)

    local plrs = players:GetPlayers()
    for i = 1, #plrs do
        local plr = plrs[i]
        if plr ~= lp and plr.Character and plr.Character:FindFirstChild('HumanoidRootPart') then
            local isTeammate = true
            if teamCount > 1 and lp.Team ~= nil and plr.Team ~= nil and lp.Team ~= plr.Team then
                isTeammate = false
            end
            
            if isTeammate then
                local eHum = plr.Character:FindFirstChildOfClass('Humanoid')
                if not eHum or not eHum.Sit then
                    table.insert(potentialTargets, plr.Character)
                end
            end
        end
    end

    local bots = getActiveBots()
    for i = 1, #bots do
        local bot = bots[i]
        if bot:FindFirstChild('HumanoidRootPart') then
            local eHum = bot:FindFirstChildOfClass('Humanoid')
            if not eHum or not eHum.Sit then
                table.insert(potentialTargets, bot)
            end
        end
    end

    if #potentialTargets == 0 then return nil end

    if autoChooseWr.Value then
        local bestAutoTarget = nil
        local bestAutoDist = math.huge
        local qbHRP = lp.Character and lp.Character:FindFirstChild('HumanoidRootPart')
        local qbPos = qbHRP and qbHRP.Position or Vector3.zero

        for i = 1, #potentialTargets do
            local char = potentialTargets[i]
            local hrp = char:FindFirstChild('HumanoidRootPart')
            if hrp then
                local _, onScreen = camera:WorldToViewportPoint(hrp.Position)
                if onScreen and isWROpen(char) then
                    local dist = tonumber((hrp.Position - qbPos).Magnitude) or 0
                    if dist < bestAutoDist then
                        bestAutoDist = dist
                        bestAutoTarget = char
                    end
                end
            end
        end
        
        if bestAutoTarget then
            return bestAutoTarget
        end
    end

    local mousePos2D = userInputService:GetMouseLocation()
    local bestManualTarget = nil
    local bestMouseDist = math.huge

    for i = 1, #potentialTargets do
        local char = potentialTargets[i]
        local hrp = char:FindFirstChild('HumanoidRootPart')
        if hrp then
            local screenPos, onScreen = camera:WorldToViewportPoint(hrp.Position)
            if onScreen then
                local dist = tonumber((Vector2.new(screenPos.X, screenPos.Y) - mousePos2D).Magnitude) or 0
                if dist < bestMouseDist then
                    bestMouseDist = dist
                    bestManualTarget = char
                end
            end
        end
    end

    return bestManualTarget
end

local calculateRouteDirection = function(targetChar)
    if not targetChar then return 'Mag' end
    local targetHRP = targetChar:FindFirstChild('HumanoidRootPart')
    if not targetHRP then return 'Mag' end
    
    local lpChar = lp.Character
    local lpHRP = lpChar and lpChar:FindFirstChild('HumanoidRootPart')
    if not lpHRP then return 'Mag' end

    local route, moveDir = findRoute(targetChar)
    local dist = tonumber((targetHRP.Position - lpHRP.Position).Magnitude) or 0
    if dist < 40 then return 'Bullet' end
    
    local dbDistance = math.huge
    local teamCount = 0
    pcall(function() teamCount = tonumber(#game:GetService('Teams'):GetTeams()) or 0 end)

    local plrs = players:GetPlayers()
    for i = 1, #plrs do
        local plr = plrs[i]
        if plr ~= lp and plr.Character then
            local eHRP = plr.Character:FindFirstChild('HumanoidRootPart')
            if eHRP and eHRP ~= targetHRP then
                local isEnemy = true
                if teamCount > 1 and lp.Team ~= nil and plr.Team ~= nil and lp.Team == plr.Team then
                    isEnemy = false
                end
                if isEnemy then
                    local d = tonumber((eHRP.Position - targetHRP.Position).Magnitude) or 0
                    if d < dbDistance then dbDistance = d end
                end
            end
        end
    end

    local bots = getActiveBots()
    for i = 1, #bots do
        local bot = bots[i]
        local bHRP = bot:FindFirstChild('HumanoidRootPart')
        if bHRP and bHRP ~= targetHRP then
            local d = tonumber((bHRP.Position - targetHRP.Position).Magnitude) or 0
            if d < dbDistance then dbDistance = d end
        end
    end

    local within = function(tbl, val)
        for i = 1, #tbl do
            if tbl[i] == val then return true end
        end
        return false
    end

    local forwardRoutes = {'go/fade', 'post/corner', 'seam', 'curl/comeback', 'stationary'}
    local sidewayRoutes = {'in/out', 'flat', 'wheel'}
    
    if route == 'slant' or route == 'hitch' or route == 'drag' or route == 'in/out' or route == 'flat' then
        return 'Bullet'
    elseif within(forwardRoutes, route) then
        if dbDistance > 5 then return ((tonumber(angle) or 45) < 40) and 'Jump' or 'Dime'
        elseif dbDistance > 2 then return 'Dive' end
        return 'Mag'
    elseif within(sidewayRoutes, route) then
        if dbDistance > 4 then return 'Dime' end
        return 'Jump'
    end
    return 'Dime'
end

local getModeLead = function(modeName)
    if modeName == 'Dime' then return leadDime
    elseif modeName == 'Mag' then return leadMag
    elseif modeName == 'Dive' then return leadDive
    elseif modeName == 'Jump' then return leadJump
    elseif modeName == 'Bullet' then return leadBullet
    end
    return 8.6
end

local getModeYLead = function(modeName)
    if modeName == 'Dime' then return yLeadDime
    elseif modeName == 'Mag' then return yLeadMag
    elseif modeName == 'Dive' then return yLeadDive
    elseif modeName == 'Jump' then return yLeadJump
    elseif modeName == 'Bullet' then return yLeadBullet
    end
    return 0
end

local getPing = function()
    local networkPing = 0
    pcall(function() networkPing = tonumber(lp:GetNetworkPing()) or 0 end)
    local dataPing = 0
    pcall(function() dataPing = (tonumber(stats.Network.ServerStatsItem['Data Ping']:GetValue()) or 0) / 1000 end)
    if dataPing == 0 then dataPing = networkPing end
    return networkPing + dataPing
end

local solveKinematics = function(origin, targetPos, gravityMag)
    local g = tonumber(gravityMag) or 28
    local displacement = targetPos - origin
    local x = tonumber(Vector3.new(displacement.X, 0, displacement.Z).Magnitude) or 0
    local y = tonumber(displacement.Y) or 0
    
    local inner = (x^2) + (y^2)
    local root = tonumber(math.sqrt(math.max(inner, 0))) or 0
    
    local baseAngleRad = math.rad(45)
    if x > 0.01 then
        local atanRes = tonumber(math.atan((y + root) / x)) or baseAngleRad
        if atanRes and atanRes == atanRes then
            baseAngleRad = atanRes
        end
    end
    
    local angleRad = tonumber(math.clamp(baseAngleRad * 0.85, math.rad(-15), math.rad(65))) or 0
    
    local cosA = tonumber(math.cos(angleRad)) or 1
    local tanA = tonumber(math.tan(angleRad)) or 0
    
    local v0 = 95
    local denom = 2 * (cosA^2) * (x * tanA - y)
    
    if denom > 0.001 then
        local num = g * (x^2)
        local res = tonumber(math.sqrt(num / denom)) or v0
        if res and res == res and res ~= math.huge then
            v0 = res
        end
    end
    
    local angleDeg = tonumber(math.deg(angleRad)) or 45
    return v0, angleDeg
end

local autoAim = function(targetHRP)
    local head = lp.Character:FindFirstChild('Head')
    local origin = head and head.Position or lp.Character.HumanoidRootPart.Position
    
    local targetChar = targetHRP.Parent
    local targetHeadObj = targetChar and targetChar:FindFirstChild('Head')
    local targetHead = targetHeadObj and targetHeadObj.Position or targetHRP.Position + Vector3.new(0, 1.5, 0)
    
    local moveDir = Vector3.zero
    local targetHum = targetChar and targetChar:FindFirstChildOfClass('Humanoid')
    if targetHum then
        local isBot = targetChar:FindFirstAncestor('npcwr') ~= nil
        if isBot then
            local wtpDiff = targetHum.WalkToPoint - targetHRP.Position
            local dir = Vector3.new(wtpDiff.X, 0, wtpDiff.Z)
            moveDir = dir.Magnitude > 0.1 and dir.Unit or Vector3.zero
        else
            local md = targetHum.MoveDirection
            local flatMd = Vector3.new(md.X, 0, md.Z)
            moveDir = flatMd.Magnitude > 0.01 and flatMd.Unit or Vector3.zero
        end
    end
    
    local ping = tonumber(getPing()) or 0
    local speed = 20
    
    local modeName = ModeOrder[modeIndex]
    local isChestPass = (modeName == 'Bullet' or target and (findRoute(target) == 'slant' or findRoute(target) == 'drag' or findRoute(target) == 'in/out' or findRoute(target) == 'flat' or findRoute(target) == 'hitch' or findRoute(target) == 'curl/comeback'))
    local routeStr = target and findRoute(target) or 'go/fade'
    
    local activePower = tonumber(power) or 60
    if modeName == 'Bullet' or (autoPower.Value and isChestPass) or highPowerOnly.Value then
        activePower = 95
    end
    
    local lDivisor = 60
    if activePower > 75 then
        lDivisor = 60 + ((activePower - 75) * 1.5)
    end
    
    local distToTarget = tonumber((targetHRP.Position - origin).Magnitude) or 0
    local estFlightTime = distToTarget / (tonumber(lDivisor) or 60)
    
    local currentHVel = activePower * (tonumber(math.cos(math.rad(tonumber(angle) or 45))) or 1)
    if currentHVel < 30 then currentHVel = 55 end
    
    local estHVel = (modeName == 'Bullet' or isChestPass) and 90 or currentHVel
    
    local modeLeadScale = (tonumber(getModeLead(modeName)) or 8.6) * 3.05
    local selectedModeYLead = tonumber(getModeYLead(modeName)) or 0
    
    local routeMultipliers = {
        ['slant'] = 0.45,
        ['drag'] = 0.6,
        ['in/out'] = 0.65,
        ['flat'] = 0.65,
        ['wheel'] = 0.9,
        ['go/fade'] = 1.0,
        ['post/corner'] = 0.85,
        ['seam'] = 0.85,
        ['hitch'] = 0.1,
        ['curl/comeback'] = 0.1,
        ['stationary'] = 0.0
    }
    local rMult = tonumber(routeMultipliers[routeStr]) or 1.0
    
    local dirUnit = moveDir.Magnitude > 0.01 and moveDir.Unit or Vector3.zero
    
    local targetBase = (isChestPass or modeName == 'Bullet') and targetHRP.Position or targetHead
    
    local standingStill = (routeStr == 'stationary')
    
    if standingStill then
        leadPos = targetHead
    else
        leadPos = targetBase + (moveDir * speed * estFlightTime * rMult) + (moveDir * speed * ping * rMult) + (dirUnit * modeLeadScale * rMult)
        leadPos = leadPos + (dirUnit * (tonumber(throwLeadOffset.Value) or 0))
        
        if isChestPass or modeName == 'Bullet' then
            leadPos = Vector3.new(leadPos.X, targetHead.Y, leadPos.Z)
            selectedModeYLead = 0
        end
        
        leadPos = leadPos + Vector3.new(0, selectedModeYLead, 0)
        leadPos = leadPos + Vector3.new(0, tonumber(throwHeightOffset.Value) or 0, 0)
        
        if routeStr == 'curl/comeback' or routeStr == 'hitch' then
            leadPos = leadPos + Vector3.new(0, -5, 0)
        end
    end
    
    local forceAutoAngle = (modeName == 'Bullet' or isChestPass or (tonumber(power) or 60) == 95 or highPowerOnly.Value)
    if not autoAngle.Value and not forceAutoAngle then
        leadPos = leadPos + Vector3.new(0, tonumber(customHeight.Value) or 0, 0)
    end
    
    if antiDB.Value then
        local pushVec = Vector3.zero
        local plrs = players:GetPlayers()
        local teamCount = 0
        pcall(function() teamCount = tonumber(#game:GetService('Teams'):GetTeams()) or 0 end)

        for i = 1, #plrs do
            local plr = plrs[i]
            if plr ~= lp and plr.Character then
                local isEnemy = true
                if teamCount > 1 and lp.Team ~= nil and plr.Team ~= nil and lp.Team == plr.Team then
                    isEnemy = false
                end
                if isEnemy then
                    local eHRP = plr.Character:FindFirstChild('HumanoidRootPart')
                    if eHRP then
                        local dist = tonumber(Vector3.new(eHRP.Position.X - leadPos.X, 0, eHRP.Position.Z - leadPos.Z).Magnitude) or 0
                        if dist < (tonumber(antiDBThreshold.Value) or 15) then
                            local away = (leadPos - eHRP.Position)
                            away = Vector3.new(away.X, 0, away.Z)
                            if away.Magnitude > 0 then
                                pushVec = pushVec + (away.Unit * ((tonumber(antiDBThreshold.Value) or 15) - dist))
                            end
                        end
                    end
                end
            end
        end
        leadPos = pushVec + leadPos
    end

    local fPos = Vector3.zero
    local field = workspace:FindFirstChild('Models')
    if field then field = field:FindFirstChild('Field') end
    if field then field = field:FindFirstChild('Ground') end
    if field then fPos = field.Position end

    if antiOOB.Value and fPos ~= Vector3.zero then
        local halfWidth = 75 - (tonumber(antiOOBThreshold.Value) or 5)
        local halfLength = 175 - (tonumber(antiOOBThreshold.Value) or 5)
        leadPos = Vector3.new(
            math.clamp(leadPos.X, fPos.X - halfWidth, fPos.X + halfWidth),
            leadPos.Y,
            math.clamp(leadPos.Z, fPos.Z - halfLength, fPos.Z + halfLength)
        )
    end
    
    targetLeadPos = leadPos
    
    local gMag = 28 
    local calcPower, calcAngle = solveKinematics(origin, leadPos, gMag)
    calcPower = tonumber(calcPower) or 95
    calcAngle = tonumber(calcAngle) or 45
    
    if standingStill and modeName ~= 'Bullet' and not highPowerOnly.Value then
        local dynamicThreshold = tonumber(math.clamp(4 + (distToTarget * 0.08), 5, 14)) or 10
        if calcAngle > dynamicThreshold then
            local displacement = leadPos - origin
            local x = tonumber(Vector3.new(displacement.X, 0, displacement.Z).Magnitude) or 0
            local y = tonumber(displacement.Y) or 0
            local aRad = tonumber(math.rad(dynamicThreshold)) or 0.1
            local denom = 2 * (math.cos(aRad)^2) * (x * math.tan(aRad) - y)
            
            if denom > 0.001 then
                local newPwr = tonumber(math.sqrt((gMag * x^2) / denom)) or calcPower
                if newPwr == newPwr and newPwr ~= math.huge then
                    calcAngle = dynamicThreshold
                    calcPower = newPwr
                end
            end
        end
    end
    
    if highPowerOnly.Value then
        power = 95
        local displacement = leadPos - origin
        local x = tonumber(Vector3.new(displacement.X, 0, displacement.Z).Magnitude) or 0
        local y = tonumber(displacement.Y) or 0
        
        local v2 = 95^2
        local v4 = 95^4
        local gx = gMag * x
        local discriminant = v4 - gMag * (gMag * x^2 + 2 * y * v2)
        
        if discriminant >= 0 then
            angle = tonumber(math.clamp(math.deg(math.atan((v2 - math.sqrt(discriminant)) / gx)) * 0.94, -15, 85)) or 45
        else
            angle = 45
        end
    elseif modeName == 'Bullet' or (autoPower.Value and isChestPass) then
        power = 95
        local displacement = leadPos - origin
        local h = tonumber(Vector3.new(displacement.X, 0, displacement.Z).Magnitude) or 0
        local v = tonumber(displacement.Y) or 0
        local t_est = h / 95
        local drop = 0.5 * 28 * t_est * t_est
        angle = tonumber(math.clamp(math.deg(math.atan2(v + drop, h)), -15, 45)) or 15
    else
        if autoPower.Value then
            power = tonumber(math.clamp(calcPower, 0, 95)) or 60
        end
        if autoAngle.Value then
            angle = tonumber(math.clamp(calcAngle, -15, 90)) or 45
        end
    end
    
    if not autoAngle.Value and not forceAutoAngle then
        angle = tonumber(math.clamp(calcAngle, -15, 90)) or 45
    end
    
    local safePower = tonumber(power) or 60
    local safeAngle = tonumber(angle) or 45
    local angleRad = tonumber(math.rad(safeAngle)) or 0
    
    local hDirRaw = Vector3.new(leadPos.X - origin.X, 0, leadPos.Z - origin.Z)
    local hDir = hDirRaw.Magnitude > 0.01 and hDirRaw.Unit or head.CFrame.LookVector
    local dirVelocity = (hDir * (tonumber(math.cos(angleRad)) or 1) + Vector3.new(0, tonumber(math.sin(angleRad)) or 0, 0)) * safePower
    
    direction = dirVelocity.Unit * safePower
    
    local hVel = safePower * (tonumber(math.cos(angleRad)) or 1)
    if hVel > 0.1 then
        local xDist = tonumber(Vector3.new(leadPos.X - origin.X, 0, leadPos.Z - origin.Z).Magnitude) or 0
        airtime = xDist / hVel
    else
        airtime = 0
    end
    
    return safeAngle
end

local beamProjectile = function(g, v0, x0, t1)
    local c = 0.5 * 0.5 * 0.5
    local safeT1 = tonumber(t1) or 0.1
    local p3 = 0.5 * g * safeT1 * safeT1 + v0 * safeT1 + x0
    local p2 = p3 - (g * safeT1 * safeT1 + v0 * safeT1) / 3
    local p1 = (c * g * safeT1 * safeT1 + 0.5 * v0 * safeT1 + x0 - c * (x0 + p3)) / (3 * c) - p2

    local curve0 = tonumber((p1 - x0).Magnitude) or 0
    local curve1 = tonumber((p2 - p3).Magnitude) or 0

    local b = (x0 - p3).Unit
    local r1 = (p1 - x0).Unit
    local u1 = r1:Cross(b).Unit
    local r2 = (p2 - p3).Unit
    local u2 = r2:Cross(b).Unit
    b = u1:Cross(r1).Unit

    local cf1 = CFrame.new(
        x0.X, x0.Y, x0.Z,
        r1.X, u1.X, b.X,
        r1.Y, u1.Y, b.Y,
        r1.Z, u1.Z, b.Z
    )

    local cf2 = CFrame.new(
        p3.X, p3.Y, p3.Z,
        r2.X, u2.X, b.X,
        r2.Y, u2.Y, b.Y,
        r2.Z, u2.Z, b.Z
    )

    return curve0, -curve1, cf1, cf2
end

userInputService.InputBegan:Connect(function(input, gpe)
    if gpe then return end
    local char = lp.Character
    if not char or not char:FindFirstChild('Football') then return end
    
    if input.KeyCode == throwBallAwayKeybind.Value then
        local fPos = Vector3.zero
        local field = workspace:FindFirstChild('Models')
        if field then field = field:FindFirstChild('Field') end
        if field then field = field:FindFirstChild('Ground') end
        if field then fPos = field.Position end
        
        local side = math.random(1, 2) == 1 and -1 or 1
        local throwTarget = fPos + Vector3.new(side * 120, 0, math.random(-100, 100))
        
        local head = char:FindFirstChild('Head')
        local origin = head and head.Position or char.HumanoidRootPart.Position
        
        isThrowingAway = true
        power = 95
        angle = 25
        
        local angleRad = tonumber(math.rad(angle)) or 0
        local hDir = Vector3.new(throwTarget.X - origin.X, 0, throwTarget.Z - origin.Z).Unit
        local dirVelocity = (hDir * (tonumber(math.cos(angleRad)) or 1) + Vector3.new(0, tonumber(math.sin(angleRad)) or 0, 0)) * 95
        direction = dirVelocity.Unit * 95
        
        local hVel = 95 * (tonumber(math.cos(angleRad)) or 1)
        airtime = hVel > 0.1 and ((tonumber(Vector3.new(throwTarget.X - origin.X, 0, throwTarget.Z - origin.Z).Magnitude) or 0) / hVel) or 1
        
        local hum = char:FindFirstChildOfClass('Humanoid')
        local throwAnim = replicatedStorage:FindFirstChild('Animations') and replicatedStorage.Animations:FindFirstChild('Throw')
        if hum and throwAnim then
            local animator = hum:FindFirstChild('Animator')
            if animator then
                local track = animator:LoadAnimation(throwAnim)
                track:Play()
            end
        end
        return
    end

    if input.KeyCode == increaseAngleKeybind.Value then
        customHeight.Value = (tonumber(customHeight.Value) or 0) + 5
    elseif input.KeyCode == decreaseAngleKeybind.Value then
        customHeight.Value = (tonumber(customHeight.Value) or 0) - 5
    end
    
    if not autoSelectThrowMode.Value and QBKeybinds[input.KeyCode] then
        local desiredMode = QBKeybinds[input.KeyCode]
        for i = 1, #ModeOrder do
            if ModeOrder[i] == desiredMode then
                modeIndex = i
                break
            end
        end
    end

    if input.KeyCode == lockKeybind.Value then
        if target or targetLocked then
            targetLocked = not targetLocked
            if targetLocked then
                lockedTarget = target
                if LockToggleBtn then LockToggleBtn.TextColor3 = Color3.fromRGB(255, 50, 50) end
                if LockedLabel then LockedLabel.Visible = true end
            else
                lockedTarget = nil
                if LockToggleBtn then LockToggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255) end
                if LockedLabel then LockedLabel.Visible = false end
            end
        end
    end
end)

local triggerThrowJump = function()
    if autoJumpWhenThrow.Value then
        task.delay(0.05, function()
            local char = lp.Character
            if char then
                local hum = char:FindFirstChildOfClass('Humanoid')
                if hum and hum:GetState() ~= Enum.HumanoidStateType.Jumping then
                    hum:ChangeState(Enum.HumanoidStateType.Jumping)
                end
            end
        end)
    end
end

task.spawn(function()
    local bindAnimation = function(char)
        local humanoid = char:WaitForChild('Humanoid', 5)
        if not humanoid then return end
        local animator = humanoid:WaitForChild('Animator', 5)
        if not animator then return end
        
        animator.AnimationPlayed:Connect(function(track)
            local throwAnim = replicatedStorage:FindFirstChild('Animations') and replicatedStorage.Animations:FindFirstChild('Throw')
            if throwAnim and track.Animation and (track.Animation == throwAnim or track.Animation.AnimationId == throwAnim.AnimationId) then
                track:GetPropertyChangedSignal('IsPlaying'):Connect(function()
                    if track.IsPlaying then
                        if not isThrowing then
                            isThrowing = true
                            triggerThrowJump()
                            task.delay(0.12, function()
                                firedRemote = true
                                performThrow()
                            end)
                        end
                    else
                        isThrowing = false
                        firedRemote = false
                        isThrowingAway = false
                    end
                end)
                
                if track.IsPlaying and not isThrowing then
                    isThrowing = true
                    triggerThrowJump()
                    task.delay(0.12, function()
                        firedRemote = true
                        performThrow()
                    end)
                end
            end
        end)
    end

    if lp.Character then
        bindAnimation(lp.Character)
    end
    lp.CharacterAdded:Connect(function(char)
        bindAnimation(char)
    end)
end)

local setupSackHandler = function(character)
    character.ChildAdded:Connect(function(v)
        if not autoThrowAfterSack.Value then return end
        if not v:IsA('LocalScript') then return end
        if not v.Name:lower():find('tackle') then return end

        task.wait()

        local humanoid = character:FindFirstChildOfClass('Humanoid')
        if not humanoid then return end

        if autoChooseWr.Value then
            local openWR = nil
            local bestDist = math.huge
            local mousePos2D = userInputService:GetMouseLocation()
            
            local teamCount = 0
            pcall(function() teamCount = tonumber(#game:GetService('Teams'):GetTeams()) or 0 end)
            
            local plrs = players:GetPlayers()
            for i = 1, #plrs do
                local plr = plrs[i]
                if plr ~= lp and plr.Character then
                    local isTeammate = true
                    if teamCount > 1 and lp.Team ~= nil and plr.Team ~= nil and lp.Team ~= plr.Team then
                        isTeammate = false
                    end
                    
                    if isTeammate then
                        local eHrp = plr.Character:FindFirstChild('HumanoidRootPart')
                        local eHum = plr.Character:FindFirstChildOfClass('Humanoid')
                        if eHrp and (not eHum or not eHum.Sit) and isWROpen(plr.Character) then
                            local screenPos, onScreen = camera:WorldToViewportPoint(eHrp.Position)
                            if onScreen then
                                local dist = tonumber((Vector2.new(screenPos.X, screenPos.Y) - mousePos2D).Magnitude) or 0
                                if dist < bestDist then
                                    bestDist = dist
                                    openWR = plr.Character
                                end
                            end
                        end
                    end
                end
            end

            if openWR then
                target = openWR
                targetLocked = true
                lockedTarget = openWR
            end
        end

        if target then
            local throwAnim = replicatedStorage:FindFirstChild('Animations') and replicatedStorage.Animations:FindFirstChild('Throw')
            if throwAnim then
                local animator = humanoid:FindFirstChild('Animator')
                if animator then
                    local track = animator:LoadAnimation(throwAnim)
                    track:Play()
                end
            end
        end
    end)
end

if lp.Character then
    setupSackHandler(lp.Character)
end
lp.CharacterAdded:Connect(setupSackHandler)

local updateHighlights = function(isActive)
    if not isActive then
        if highlight then highlight:Destroy(); highlight = nil end
        return
    end

    if target then
        if not highlight then
            highlight = Instance.new('Highlight')
        end
        highlight.Adornee = target
        highlight.Parent = target
        highlight.FillTransparency = 1
        highlight.OutlineColor = targetLocked and Color3.new(0, 0, 0) or Color3.fromRGB(255, 255, 255)
        highlight.OutlineTransparency = 0
    elseif highlight then
        highlight:Destroy()
        highlight = nil
    end
end

workspace.ChildAdded:Connect(function(v)
    if not enableQbAimbot.Value then return end
    if v:IsA('BasePart') and v.Name == 'Football' then
        task.wait()
        local lpChar = lp.Character
        local lpHead = lpChar and lpChar:FindFirstChild('Head')
        if not lpHead then return end
        
        if v:GetAttribute('LocalAimbotBall') or (v.Position - lpHead.Position).Magnitude < 15 then
            local tAttach0 = Instance.new('Attachment', workspace.Terrain)
            local tAttach1 = Instance.new('Attachment', workspace.Terrain)
            
            local tBeam = Instance.new('Beam')
            tBeam.Attachment0 = tAttach0
            tBeam.Attachment1 = tAttach1
            tBeam.Segments = 7500
            tBeam.Width0 = 1
            tBeam.Width1 = 1
            tBeam.FaceCamera = true
            tBeam.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255))
            tBeam.Transparency = NumberSequence.new({
                NumberSequenceKeypoint.new(0, 1),
                NumberSequenceKeypoint.new(0.01, 0),
                NumberSequenceKeypoint.new(1, 0)
            })
            tBeam.Parent = workspace.Terrain
            
            local tPosPart = Instance.new('Part', workspace.Terrain)
            tPosPart.Anchored = true
            tPosPart.CanCollide = false
            tPosPart.CastShadow = false
            tPosPart.Size = Vector3.new(3, 3, 3)
            tPosPart.Shape = Enum.PartType.Ball
            tPosPart.Color = Color3.fromRGB(0, 0, 0)
            
            local safeDirection = direction or Vector3.new(0, 1, 0)
            local safeAirtime = math.max(tonumber(airtime) or 0.1, 0.1)
            local curve0, curve1, cf1, cf2 = beamProjectile(Vector3.new(0, -28, 0), safeDirection, lpHead.Position + (safeDirection.Unit * 5), safeAirtime)
            
            tBeam.CurveSize0 = curve0
            tBeam.CurveSize1 = curve1
            
            tAttach0.WorldCFrame = cf1
            tAttach1.WorldCFrame = cf2
            
            tPosPart.Position = Vector3.new(cf2.X, cf2.Y, cf2.Z)
            
            task.delay(safeAirtime, function()
                tBeam:Destroy()
                tAttach0:Destroy()
                tAttach1:Destroy()
                tPosPart:Destroy()
            end)
        end
    end
end)

runService.RenderStepped:Connect(function()
    if not enableQbAimbot.Value then
        updateHUDVisibility(false)
        updateHighlights(false)
        if beam then beam.Enabled = false end
        if posPart then posPart.Position = Vector3.new(0, -9999, 0) end
        if attach0 then attach0.WorldPosition = Vector3.new(0, -9999, 0) end
        if attach1 then attach1.WorldPosition = Vector3.new(0, -9999, 0) end
        target = nil
        return
    end

    if not sg or not sg.Parent then return end

    local char = lp.Character
    if not char then return end
    
    local head = char:FindFirstChild('Head')
    local hrp = char:FindFirstChild('HumanoidRootPart')
    if not head or not hrp then return end

    local football = char:FindFirstChild('Football')
    local hasFootball = (football ~= nil)
    
    if hasFootball then
        football:SetAttribute('LocalAimbotBall', true)
        local fHandle = football:FindFirstChild('Handle')
        if fHandle then fHandle:SetAttribute('LocalAimbotBall', true) end
    end
    
    local playerGui = lp:WaitForChild('PlayerGui', 10)
    local ballGui = playerGui and playerGui:FindFirstChild('BallGui')
    
    if autoJuke.Value and hasFootball and ballGui then
        local fPos = Vector3.zero
        local field = workspace:FindFirstChild('Models')
        if field then field = field:FindFirstChild('Field') end
        if field then field = field:FindFirstChild('Ground') end
        if field then fPos = field.Position end
        
        local minX = fPos.X - (155 / 2)
        local maxX = fPos.X + (155 / 2)
        local minZ = fPos.Z - (355 / 2)
        local maxZ = fPos.Z + (355 / 2)

        local dodgeVec = Vector3.zero
        local threatCount = 0

        local plrs = players:GetPlayers()
        local teamCount = 0
        pcall(function() teamCount = tonumber(#game:GetService('Teams'):GetTeams()) or 0 end)
        
        for i = 1, #plrs do
            local plr = plrs[i]
            if plr ~= lp and plr.Character then
                local isEnemy = true
                if teamCount > 1 and lp.Team ~= nil and plr.Team ~= nil and lp.Team == plr.Team then
                    isEnemy = false
                end
                
                if isEnemy then
                    local eHrp = plr.Character:FindFirstChild('HumanoidRootPart')
                    if eHrp then
                        local distToMe = tonumber((eHrp.Position - hrp.Position).Magnitude) or 0
                        if distToMe < 45 then
                            local eVel = eHrp.AssemblyLinearVelocity or eHrp.Velocity or Vector3.zero
                            local eSpeed = tonumber(Vector3.new(eVel.X, 0, eVel.Z).Magnitude) or 0
                            local tta = distToMe / math.max(eSpeed, 1)
                            
                            local futureTime = math.min(tta, 1)
                            local eFuture = eHrp.Position + (eVel * futureTime)
                            local myVel = hrp.AssemblyLinearVelocity or hrp.Velocity or Vector3.zero
                            local myFuture = hrp.Position + (myVel * futureTime)
                            
                            local toThreat = eFuture - myFuture
                            local futureDist = tonumber(Vector3.new(toThreat.X, 0, toThreat.Z).Magnitude) or 0
                            
                            if futureDist < 20 or distToMe < 25 then
                                threatCount = threatCount + 1
                                local awayDir = myFuture - eFuture
                                awayDir = Vector3.new(awayDir.X, 0, awayDir.Z)
                                if awayDir.Magnitude < 0.1 then
                                    awayDir = hrp.CFrame.RightVector
                                end
                                awayDir = awayDir.Unit
                                
                                local weight = math.clamp(45 - distToMe, 0, 45)
                                dodgeVec = dodgeVec + (awayDir * weight)
                            end
                        end
                    end
                end
            end
        end

        local hum = char:FindFirstChildOfClass('Humanoid')
        if hum then
            local checkPos = hrp.Position
            local outOfBoundsPush = Vector3.zero
            
            if checkPos.X < minX + 5 then outOfBoundsPush = outOfBoundsPush + Vector3.new(1, 0, 0) end
            if checkPos.X > maxX - 5 then outOfBoundsPush = outOfBoundsPush + Vector3.new(-1, 0, 0) end
            if checkPos.Z < minZ + 5 then outOfBoundsPush = outOfBoundsPush + Vector3.new(0, 0, 1) end
            if checkPos.Z > maxZ - 5 then outOfBoundsPush = outOfBoundsPush + Vector3.new(0, 0, -1) end
            
            local targetJukeDir = Vector3.zero
            if threatCount > 0 then
                targetJukeDir = dodgeVec.Unit
                if outOfBoundsPush.Magnitude > 0 then
                    targetJukeDir = (targetJukeDir + outOfBoundsPush * 2).Unit
                end
            elseif outOfBoundsPush.Magnitude > 0 then
                targetJukeDir = outOfBoundsPush.Unit
            end
            
            if targetJukeDir.Magnitude > 0 then
                smoothedJukeDir = smoothedJukeDir:Lerp(targetJukeDir, 0.25)
                hum:Move(smoothedJukeDir, false)
            else
                smoothedJukeDir = Vector3.zero
            end
        end
    end

    local isTracking = hasFootball and (ballGui ~= nil)

    if isTracking then
        if not hideCards.Value then
            updateHUDVisibility(true)
        else
            updateHUDVisibility(false)
        end
        
        if not isThrowingAway then
            local newTarget = getTarget()
            if newTarget then
                lastValidTarget = newTarget
            elseif lastValidTarget and not lastValidTarget:FindFirstChild('HumanoidRootPart') then
                lastValidTarget = nil
            end
            
            if throwAimbot.Value then
                target = lastValidTarget
                updateHighlights(false)
                
                local targetPos
                if isThrowing and lockedMousePos then
                    targetPos = lockedMousePos
                else
                    targetPos = mouse.Hit.Position
                    lockedMousePos = targetPos
                end
                
                local headPos = head.Position
                local gMag = 28
                local calcPower, calcAngle = solveKinematics(headPos, targetPos, gMag)
                calcPower = tonumber(calcPower) or 95
                calcAngle = tonumber(calcAngle) or 45
                
                if autoPower.Value then
                    power = math.clamp(calcPower, 0, 95)
                end
                
                if autoAngle.Value then
                    angle = math.clamp(calcAngle, -15, 90)
                else
                    angle = math.clamp(tonumber(customHeight.Value) or 0, -15, 90)
                end
                
                local safePower = tonumber(power) or 60
                local safeAngle = tonumber(angle) or 45
                local angleRad = tonumber(math.rad(safeAngle)) or 0
                
                local hDirRaw = Vector3.new(targetPos.X - headPos.X, 0, targetPos.Z - headPos.Z)
                local hDir = hDirRaw.Magnitude > 0.01 and hDirRaw.Unit or hrp.CFrame.LookVector
                
                local dirVelocity = (hDir * (tonumber(math.cos(angleRad)) or 1) + Vector3.new(0, tonumber(math.sin(angleRad)) or 0, 0)) * safePower
                direction = dirVelocity.Unit * safePower
                
                local hVel = safePower * (tonumber(math.cos(angleRad)) or 1)
                if hVel > 0.1 then
                    local xDist = tonumber(Vector3.new(targetPos.X - headPos.X, 0, targetPos.Z - headPos.Z).Magnitude) or 0
                    airtime = xDist / hVel
                else
                    airtime = 0
                end
                
                targetLeadPos = targetPos
            else
                target = newTarget or lastValidTarget
                updateHighlights(true)
                if target and hrp then
                    local tHRP = target:FindFirstChild('HumanoidRootPart')
                    if tHRP then
                        if autoSelectThrowMode.Value then
                            local m = calculateRouteDirection(target)
                            for i = 1, #ModeOrder do
                                if ModeOrder[i] == m then
                                    modeIndex = i
                                    break
                                end
                            end
                            
                            local targetCurrentRoute = select(1, findRoute(target))
                            if ModeOrder[modeIndex] == 'Bullet' and (targetCurrentRoute == 'go/fade' or targetCurrentRoute == 'post/corner') then
                                for i = 1, #ModeOrder do
                                    if ModeOrder[i] == 'Mag' then
                                        modeIndex = i
                                        break
                                    end
                                end
                            end
                        end
                        
                        autoAim(tHRP)
                    end
                end
            end
        else
            target = nil
            updateHighlights(false)
        end
        
        if autoChangePowerUI.Value then
            if ballGui and ballGui:FindFirstChild('Frame0') then
                local frame0 = ballGui.Frame0
                local safePower = tonumber(power) or 60
                if safePower ~= safePower then safePower = 60 end
                
                local displayPower = math.round(safePower / 5) * 5
                
                local txt = frame0:FindFirstChildOfClass('TextLabel')
                if txt then txt.Text = tostring(math.floor(displayPower)) end
                
                local frames = frame0:GetChildren()
                for i = 1, #frames do
                    local frame = frames[i]
                    if frame.Name ~= 'Disp' then
                        local frameNum = tonumber(frame.Name) or 0
                        frame.BackgroundTransparency = ((tonumber(frameNum) or 0) <= (tonumber(displayPower) or 0)) and 0 or 0.9
                    end
                end
            end
        end
        
        local safePowForCard = tonumber(power) or 60
        if safePowForCard ~= safePowForCard then safePowForCard = 60 end
        
        if HUDCards['Angle'] then 
            local forceAutoAngle = (ModeOrder[modeIndex] == 'Bullet' or (target and findRoute(target) == 'slant' or findRoute(target) == 'drag' or findRoute(target) == 'in/out' or findRoute(target) == 'flat' or findRoute(target) == 'hitch' or findRoute(target) == 'curl/comeback') or (tonumber(power) or 60) == 95 or highPowerOnly.Value)
            if not autoAngle.Value and not forceAutoAngle then
                HUDCards['Angle'].Text = tostring(math.floor(tonumber(customHeight.Value) or 0))
            else
                HUDCards['Angle'].Text = tostring(math.floor(tonumber(angle) or 45)) 
            end
        end
        
        if HUDCards['Power'] then HUDCards['Power'].Text = string.format('%.0f', safePowForCard) end
        if HUDCards['Airtime'] then HUDCards['Airtime'].Text = string.format('%.1fs', tonumber(airtime) or 0) end
        if HUDCards['Throw Type'] then HUDCards['Throw Type'].Text = tostring(ModeOrder[modeIndex] or 'N/A') end
        
        if HUDCards['Player'] then
            if throwAimbot.Value then
                HUDCards['Player'].Text = 'MOUSE'
            else
                HUDCards['Player'].Text = tostring((target and target.Name) or 'NONE')
            end
        end
    else
        updateHUDVisibility(false)
        updateHighlights(false)
        target = nil
        lastValidTarget = nil
    end

    if beam and isTracking then
        beam.Enabled = true
        local startOrigin = head.Position
        local safePowerForBeam = tonumber(power) or 60
        local drawDir = direction or Vector3.new(0, 1, 0)
        
        if throwAimbot.Value then
            if (tonumber(drawDir.Magnitude) or 0) < 0.1 then
                drawDir = Vector3.new(0, 1, 0) * safePowerForBeam
            end
        elseif not target or not targetLeadPos then
            local mouseRay = camera:ScreenPointToRay(mouse.X, mouse.Y)
            drawDir = mouseRay.Direction.Unit * safePowerForBeam
            direction = drawDir
        else
            if (tonumber(drawDir.Magnitude) or 0) < 0.1 then
                drawDir = Vector3.new(0, 1, 0) * safePowerForBeam
            end
        end
        
        local safeAirtime = math.max(tonumber(airtime) or 0.1, 0.1)
        
        local curve0, curve1, cf1, cf2 = beamProjectile(Vector3.new(0,-28,0), drawDir, startOrigin + (drawDir.Unit * 5), safeAirtime)
        
        beam.CurveSize0 = curve0
        beam.CurveSize1 = curve1
        
        if attach0 and attach1 then
            attach0.WorldCFrame = cf1
            attach1.WorldCFrame = cf2
            
            attach0.WorldPosition = Vector3.new(cf1.X, cf1.Y, cf1.Z)
            attach1.WorldPosition = Vector3.new(cf2.X, cf2.Y, cf2.Z)
            
            if posPart then posPart.Position = Vector3.new(attach1.WorldPosition.X, attach1.WorldPosition.Y, attach1.WorldPosition.Z) end
        end
    else
        if beam then beam.Enabled = false end
        if posPart then posPart.Position = Vector3.new(0, -9999, 0) end
        if attach0 then attach0.WorldPosition = Vector3.new(0, -9999, 0) end
        if attach1 then attach1.WorldPosition = Vector3.new(0, -9999, 0) end
    end
end)

local CatchingTab = Window:CreateTab({ Name = 'Catching', Icon = 'rbxassetid://6034227067' })

footballMagnets = CatchingTab:CreateToggle({
    Name = 'Enable Football Magnets',
    Default = false,
    Tip = 'Automatically pulls nearby footballs into catch range.',
})

freeFallCheck = CatchingTab:CreateToggle({
    Name = 'Magnets Freefall Check',
    Default = false,
    Tip = 'Only activates football magnets while the ball is airborne.',
})

showCatchHitbox = CatchingTab:CreateToggle({
    Name = 'Show Magnets Radius',
    Default = false,
    Tip = 'Displays the football magnets catch radius.',
})

magnetsRadius = CatchingTab:CreateSlider({
    Name = 'Magnets Catch Distance',
    Min = 0,
    Max = 25,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the maximum distance footballs can be caught from.',
})

magnetsDelay = CatchingTab:CreateSlider({
    Name = 'Magnets Catch Delay',
    Min = 0,
    Max = 1,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the delay before football magnets activate.',
})

magsType = CatchingTab:CreateDropdown({
    Name = 'Magnets Type',
    Options = {'Custom', 'Blatant', 'League', 'Legit'},
    Default = 'Custom',
    Tip = 'Selects the football magnets behavior preset.',
})

local player = game:GetService('Players').LocalPlayer

local part = Instance.new('Part')
part.Color = Color3.fromRGB(255, 255, 255)
part.Shape = Enum.PartType.Ball
part.Material = Enum.Material.ForceField
part.CastShadow = false
part.Anchored = true
part.CanCollide = false

local findClosestBall = function()
    local character = player.Character
    if not character then return end

    local humanoidRootPart = character:FindFirstChild('HumanoidRootPart')
    if not humanoidRootPart then return end

    local dist = math.huge
    local ball = nil

    for _, v in next, workspace:GetChildren() do
        if not v:IsA('BasePart') then continue end
        if v.Name ~= 'Football' then continue end

        local distance = (v.Position - humanoidRootPart.Position).Magnitude

        if distance < dist then
            dist = distance
            ball = v
        end
    end

    return ball
end

local selectedRange = function()
	local range = tonumber(magnetsRadius.Value) or 0
	local mode = tostring(magsType.Value or 'Custom'):lower()

	if mode == 'legit' then
		return range / 2
	elseif mode == 'league' then
		return range / 1.4
	elseif mode == 'blatant' then
		return range * 1.5
	end

	return range
end

task.spawn(function()
    while true do
        task.wait()

        local character = player.Character
        if not character then continue end

        local humanoid = character:FindFirstChildOfClass('Humanoid')
        if not humanoid then continue end

        local ball = findClosestBall()
        if not ball then continue end

        local range = selectedRange()

        part.Size = Vector3.new(range, range, range)
        part.CFrame = CFrame.new(ball.Position)
        part.Parent = (footballMagnets.Value and showCatchHitbox.Value) and workspace.Terrain or nil

        for _, v in next, character:GetChildren() do
            if not v:IsA('BasePart') then continue end
            if not v.Name:lower():find('catch') then continue end

            local distance = (ball.Position - v.Position).Magnitude

            if freeFallCheck.Value and humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then continue end

            if footballMagnets.Value and distance < range then
                tweenService:Create(v, TweenInfo.new(magnetsDelay.Value), {Position = ball.Position}):Play()

                pcall(function()
                    firetouchinterest(v, ball, 0)
                    firetouchinterest(v, ball, 1)
                end)
            end
        end
    end
end)

CatchingTab:CreateDivider()

magEnhancer = CatchingTab:CreateToggle({
    Name = 'Enable Mag Enhancer',
    Default = false,
    Tip = 'Enhances catches on footballs already within range.',
})

magEnhancerRadius = CatchingTab:CreateSlider({
    Name = 'Mag Catch Distance',
    Min = 0,
    Max = 25,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the maximum distance the enhancer can assist catches.',
})

magEnhancerMaxAngle = CatchingTab:CreateSlider({
    Name = 'Mag Max Angle',
    Min = 50,
    Max = 70,
    Default = 50,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the maximum catch angle the enhancer can assist.',
})

task.spawn(function()
    while true do
        task.wait(0.1)

        if not magEnhancer.Value then continue end

        local character = player.Character
        if not character then continue end

        local humanoidRootPart = character:FindFirstChild('HumanoidRootPart')
        if not humanoidRootPart then continue end

        local ball = findClosestBall()
        if not ball then continue end

        local verticalDistance = ball.Position.Y - humanoidRootPart.Position.Y

        if verticalDistance > magEnhancerMaxAngle.Value then
            continue
        end

        local lookVector = humanoidRootPart.CFrame.LookVector
        local direction = (ball.Position - humanoidRootPart.Position).Unit
        local dot = lookVector:Dot(direction)

        for _, v in next, character:GetChildren() do
            if not v:IsA('BasePart') then continue end
            if not v.Name:lower():find('catch') then continue end

            local distance = (ball.Position - v.Position).Magnitude

            if dot > 0 and distance <= magEnhancerRadius.Value then
                tweenService:Create(v, TweenInfo.new(0), {Position = ball.Position}):Play()

                pcall(function()
                    firetouchinterest(v, ball, 0)
                    firetouchinterest(v, ball, 1)
                end)
            end
        end
    end
end)
    
CatchingTab:CreateDivider()

pullVector = CatchingTab:CreateToggle({
    Name = 'Enable Pull Vector',
    Default = false,
    Tip = 'Pulls nearby footballs toward your catch position.',
})

pullVectorRadius = CatchingTab:CreateSlider({
    Name = 'Pull Vector Radius',
    Min = 0,
    Max = 45,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the maximum distance footballs can be pulled from.',
})

pullVectorPower = CatchingTab:CreateSlider({
    Name = 'Pull Vector Power',
    Min = 0,
    Max = 5,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Controls how strongly footballs are pulled toward you.',
})

task.spawn(function()
    while true do
        task.wait()

        if not pullVector.Value then continue end

        local character = player.Character
        if not character then continue end

        local humanoidRootPart = character:FindFirstChild('HumanoidRootPart')
        if not humanoidRootPart then continue end

        local ball = findClosestBall()
        if not ball then continue end

        local distance = (ball.Position - humanoidRootPart.Position).Magnitude
        if distance > pullVectorRadius.Value then continue end

        local direction = (ball.Position - humanoidRootPart.Position).Unit
        humanoidRootPart.AssemblyLinearVelocity = direction * (pullVectorPower.Value * 25)
    end
end)

CatchingTab:CreateDivider()

increaseArmSize = CatchingTab:CreateToggle({
    Name = 'Increase Arm Size',
    Default = false,
    Tip = 'Increases arm size to improve catch reach.',
})

armSizeValue = CatchingTab:CreateSlider({
    Name = 'Arm Size Value',
    Min = 2,
    Max = 25,
    Default = 2,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the size applied to both arms.',
})

task.spawn(function()
    while true do
        task.wait()

        local character = player.Character
        if not character then continue end

        for _, v in next, character:GetChildren() do
            if not v:IsA('BasePart') then continue end
            if not v.Name:lower():find('t arm') then continue end

            v.Size = Vector3.new(v.Size.X, increaseArmSize.Value and armSizeValue.Value or 2, v.Size.Z)
        end
    end
end)
    
local PlayerTab = Window:CreateTab({ Name = 'Player', Icon = 'rbxassetid://103807548355126' })

customWalkSpeed = PlayerTab:CreateToggle({
    Name = 'Custom WalkSpeed',
    Default = false,
    Tip = 'Overrides your character movement speed.',
})

walkSpeedValue = PlayerTab:CreateSlider({
    Name = 'WalkSpeed Value',
    Min = 20,
    Max = 23,
    Default = 20,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the movement speed value.',
})

walkspeedType = PlayerTab:CreateDropdown({
    Name = 'WalkSpeed Type',
    Options = {'Normal', 'CFrame'},
    Default = 'Normal',
    Tip = 'Selects how movement speed is applied.',
})

task.spawn(function()
    while true do
        task.wait()
        
        if not customWalkSpeed.Value then continue end

        local character = player.Character
        if not character then continue end

        local humanoid = character:FindFirstChildOfClass('Humanoid')
        if not humanoid then continue end
        if humanoid.PlatformStand then continue end
        if humanoid.WalkSpeed == 0 then continue end

        local root = character:FindFirstChild('HumanoidRootPart')
        if not root then continue end

        local direction = Vector3.new(humanoid.MoveDirection.X, 0, humanoid.MoveDirection.Z)
        if direction.Magnitude <= 0 then continue end

        local velocity = direction.Unit * (walkspeedType.Value == 'CFrame' and (walkSpeedValue.Value / 75) or walkSpeedValue.Value)

        if humanoid:GetState() == Enum.HumanoidStateType.Running then
            local scale = walkSpeedValue.Value / math.max(humanoid.WalkSpeed, 1)

            local animator = humanoid:FindFirstChildOfClass('Animator')
            if animator then
                for _, track in next, animator:GetPlayingAnimationTracks() do
                    track:AdjustSpeed(scale)
                end
            end
        end

        if walkspeedType.Value ~= 'CFrame' then
            root.AssemblyLinearVelocity = Vector3.new(velocity.X, root.AssemblyLinearVelocity.Y, velocity.Z)
        else
            root.CFrame = root.CFrame + velocity
        end
    end
end)

PlayerTab:CreateDivider()

customJumpPower = PlayerTab:CreateToggle({
    Name = 'Custom JumpPower',
    Default = false,
    Tip = 'Overrides your character jump power.',
})

jumpPowerValue = PlayerTab:CreateSlider({
    Name = 'JumpPower Value',
    Min = 50,
    Max = 70,
    Default = 50,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the custom jump power.',
})

task.spawn(function()
    while true do
        task.wait()

        if not customJumpPower.Value then continue end
        local character = player.Character
        if not character then continue end

        local humanoid = character:FindFirstChildOfClass('Humanoid')
        if not humanoid then continue end

        local root = character:FindFirstChild('HumanoidRootPart')
        if not root then continue end

        if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then continue end
        
        task.wait()
        root.AssemblyLinearVelocity = Vector3.new(root.AssemblyLinearVelocity.X, jumpPowerValue.Value, root.AssemblyLinearVelocity.Z)
    end
end)
    
PlayerTab:CreateDivider()

angleEnhancer = PlayerTab:CreateToggle({
    Name = 'Angle Enhancer',
    Default = false,
    Tip = 'Boosts jump height when directional look changes while jumping.',
})

angleEnhancerIndicator = PlayerTab:CreateToggle({
    Name = 'Angle Enhancer Indicator',
    Default = false,
    Tip = 'Showsa notification when an angle boost is triggered.',
})
    
    autoFlip = PlayerTab:CreateToggle({
    Name = 'Auto Flip Before Landing',
    Default = false,
    Tip = 'Automatically adjusts player orientation before landing.',
})

angleEnhanceBoost = PlayerTab:CreateSlider({
    Name = 'Angle Boost Value',
    Min = 50,
    Max = 70,
    Default = 50,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the vertical velocity applied during angle boost.',
})
    
local lastTick = 0
local oldLookVector = nil

task.spawn(function()
    while true do
        task.wait()

        if not angleEnhancer.Value then continue end

        local character = player.Character
        if not character then oldLookVector = nil continue end

        local humanoid = character:FindFirstChildOfClass('Humanoid')
        local hrp = character:FindFirstChild('HumanoidRootPart')
        if not humanoid or not hrp then oldLookVector = nil continue end

        if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
            continue
        end

        local currentTime = tick()
        local newLookVector = hrp.CFrame.LookVector

        if not oldLookVector then
            oldLookVector = newLookVector
            lastTick = currentTime
            continue
        end

        local angleChange = math.acos(math.clamp(oldLookVector:Dot(newLookVector), -1, 1))
        local shiftLockEnabled = userInputService.MouseBehavior == Enum.MouseBehavior.LockCenter

        if currentTime - lastTick >= 0.2 and angleChange > math.rad(5) then
            lastTick = currentTime
            oldLookVector = newLookVector
        end

        if angleChange > math.rad(25) and currentTime - lastTick <= 2.5 then
            lastTick = currentTime
            oldLookVector = newLookVector

            task.wait()

            local vel = hrp.AssemblyLinearVelocity
            hrp.AssemblyLinearVelocity = Vector3.new(vel.X, angleEnhanceBoost.Value, vel.Z)

            if angleEnhancerIndicator.Value and (shiftLockEnabled or true) then
                local hint = Instance.new('Hint')
                hint.Text = 'Angled!'
                hint.Parent = workspace.Terrain

                task.delay(2.5, function()
                    if hint then
                        hint:Destroy()
                    end
                end)
            end
        end
    end
end)
    
local runtime, jumptime, hittime = 0, 0, 0
local arm, vLine, used, prevPs = false, nil, false, false
local seq = 0
local pack = nil

local xz = function(v: Vector3)
	local f = Vector3.new(v.X, 0, v.Z)
	return f.Magnitude > 0.001 and f.Unit or nil
end

local reset = function()
	if not pack then return end
	for _, o in next, { pack.spin, pack.ra, pack.pivot, pack.ha } do
		if o then o:Destroy() end
	end
	pack = nil
end

local flip = function(root: BasePart, head: BasePart)
	reset()

	local m = math.max(root.AssemblyMass, 1)

	local ha = Instance.new("Attachment")
	ha.Parent = head

	local pivot = Instance.new("AlignPosition")
	pivot.Mode = Enum.PositionAlignmentMode.OneAttachment
	pivot.Attachment0 = ha
	pivot.Position = head.Position + Vector3.new(0, 0.15, 0)
	pivot.MaxForce = 180000
	pivot.Responsiveness = 120
	pivot.RigidityEnabled = false
	pivot.ApplyAtCenterOfMass = false
	pivot.Parent = head

	local ra = Instance.new("Attachment")
	ra.Parent = root

	local spin = Instance.new("AngularVelocity")
	spin.Attachment0 = ra
	spin.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
	spin.AngularVelocity = Vector3.new(-9, 0, 0)
	spin.MaxTorque = 50000
	spin.Parent = root

	root:ApplyAngularImpulse(root.CFrame.RightVector * (-16 * m))

	pack = { ha = ha, pivot = pivot, ra = ra, spin = spin }
end

task.spawn(function()
	while true do
		task.wait()
	    
	    if not autoFlip.Value then continue end
	    
		local char = player.Character
		if not char then
			reset()
			arm, vLine, used, prevPs = false, nil, false, false
			continue
		end

		local hum = char:FindFirstChildOfClass("Humanoid")
		local hrp = char:FindFirstChild("HumanoidRootPart")
		local head = char:FindFirstChild("Head")

		if not hum or not hrp or not head then continue end

		local now = tick()

		if hum:GetState() == Enum.HumanoidStateType.Running then runtime = now end
		if hum:GetState() == Enum.HumanoidStateType.Jumping then jumptime = now end

		local ps = hum.PlatformStand
		if ps ~= prevPs then
			if ps then
				arm = (now - runtime <= 0.5) and (now - jumptime <= 0.7)
				vLine = xz(hrp.AssemblyLinearVelocity) or xz(hrp.CFrame.LookVector)
				used = false
			else
				arm, vLine, used = false, nil, false
				seq += 1
				reset()
			end
			prevPs = ps
		end

		if not ps or not arm or pack then continue end

		local params = RaycastParams.new()
		params.FilterType = Enum.RaycastFilterType.Exclude
		params.FilterDescendantsInstances = { char }

		local result = workspace:Raycast(head.Position, Vector3.new(0, -3, 0), params)
		local ground = result and result.Instance ~= nil

		if used or not ground or now - hittime < 0.12 then continue end

		local dist = result and (head.Position - result.Position).Magnitude or math.huge
		if dist > 1.6 then continue end

		local move = xz(hrp.AssemblyLinearVelocity) or vLine
		local face = xz(hrp.CFrame.LookVector)

		if not move or not face or face:Dot(move) < 0.78 then continue end

		hittime = now
		used = true
		seq += 1
		local k = seq

		flip(hrp, head)

		task.delay(0.24, function()
			if k == seq then
				reset()
			end
		end)
	end
end)

PlayerTab:CreateDivider()

PlayerTab:CreateButton({
    Name = 'Unlock All Gamepass',
    Tip = 'Enables all gamepass-related checks locally.',
    Callback = function()
        local replicatedFirst = game:GetService('ReplicatedFirst')

        local module
        local success = pcall(function()
            module = require(replicatedFirst:FindFirstChild('LocalSave'))
        end)

        if not success or not module then
            return
        end

        module.PlayerOwnsPass = function(a, b)
            return true
        end
    end
})

local PhysicsTab = Window:CreateTab({ Name = 'Physics', Icon = 'rbxassetid://11537490966' })
    
local boundaries = {}

if not isPractice then
    for i, v in next, workspace.Models.Boundaries:GetChildren() do
        boundaries[#boundaries + 1] = v
    end
end

antiBoundaries = PhysicsTab:CreateToggle({
    Name = 'Anti OOB',
    Default = false,
    Tip = 'Prevents players from triggering out-of-bounds zones.',
    Callback = function(v)
        for i, b in next, boundaries do
            if b then
                b.Parent = not v and workspace.Models.Boundaries or nil
            end
        end
    end
})
    
    antiBench = PhysicsTab:CreateToggle({
    Name = 'Anti Bench',
    Default = false,
    Tip = 'Prevents automatic benching.',
})

task.spawn(function()
    while true do
        task.wait()

        if not antiBench.Value then continue end

        local playerGui = player:FindFirstChild('PlayerGui')
        if not playerGui then continue end

        local benchButton = playerGui:FindFirstChild('Benched', true)
        if not benchButton then continue end

        if benchButton.BackgroundColor3 == Color3.fromRGB(120, 120, 120) then
            replicatedStorage.Remotes.CharacterSoundEvent:FireServer('Game', 'ToggleBench')
        end
    end
end)
--[[
local scrambleWall = workspace:FindFirstChild('ScrambleWall')

antiQbBoundaries = PhysicsTab:CreateToggle({
    Name = 'Anti QB Boundaries',
    Default = false,
    Tip = 'Disables invisible QB boundary walls.',
    Callback = function(v)
        if not scrambleWall then return end
        scrambleWall.Parent = v and nil or workspace
    end
})
    ]]
PhysicsTab:CreateDivider()

antiJam = PhysicsTab:CreateToggle({
    Name = 'Anti Jam',
    Default = false,
    Tip = 'Reduces player collision while moving.',
})

antiJumpCooldown = PhysicsTab:CreateToggle({
    Name = 'Anti Jump Cooldown',
    Default = false,
    Tip = 'Removes the delay between jumps.',
})

antiFreeze = PhysicsTab:CreateToggle({
    Name = 'Anti Freeze',
    Default = false,
    Tip = 'Prevents movement speed from being reduced.',
})

task.spawn(function()
    while true do
        task.wait()
        
        if antiJumpCooldown.Value then
            player.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
        end
        
        if antiFreeze.Value then
            if player.Character.Humanoid.WalkSpeed ~= 20 then
                player.Character.Humanoid.WalkSpeed = 20
            end
        end

        for _, v in next, players:GetPlayers() do
            if v == player then continue end

            local character = v.Character
            if not character then continue end

            local hum = character:FindFirstChildOfClass('Humanoid')
            if not hum then continue end

            for _, part in next, character:GetChildren() do
                if not part:IsA('BasePart') then continue end
                if part.Name == 'Head' or part.Name == 'Torso' then
                    if hum:GetState() == Enum.HumanoidStateType.Running then
                        part.CanCollide = not antiJam.Value
                    else
                        part.CanCollide = true
                    end
                end
            end
        end
    end
end)

antiBlock = PhysicsTab:CreateToggle({
    Name = 'Anti Block',
    Default = false,
    Tip = 'Reduces player collision while moving.',
})
    
task.spawn(function()
    while true do
        task.wait()

        if not antiBlock.Value then continue end

        local character = player.Character
        if not character then continue end

        local humanoid = character:FindFirstChildOfClass('Humanoid')
        if not humanoid then continue end

        for _, v in next, character:GetDescendants() do
            if not v:IsA('BodyVelocity') then continue end
            -- if not v.Name:lower():find('ffmover') then continue end

            v.Velocity = Vector3.zero
            v.MaxForce = Vector3.zero
            humanoid.WalkSpeed = 20

            pcall(function()
                v:Destroy()
            end)
        end
    end
end)

PhysicsTab:CreateDivider()

quickTP = PhysicsTab:CreateToggle({
    Name = 'Quick TP',
    Default = false,
    Tip = 'Teleports forward in the direction you are facing.',
})

quickTPPower = PhysicsTab:CreateSlider({
    Name = 'Quick TP Power',
    Min = 0,
    Max = 5,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the teleport distance.',
})

HideKeybind = PhysicsTab:CreateKeybind({
    Name = 'Quick TP Keybind',
    Default = Enum.KeyCode.Q,
    Tip = 'Key used to activate Quick TP.',
})

userInputService.InputBegan:Connect(function(input, gpe)
    if gpe then return end
    if not quickTP.Value then return end
    if input.KeyCode ~= HideKeybind.Value and input.UserInputType ~= Enum.UserInputType.Touch then return end

    local character = player.Character
    if not character then return end

    local hrp = character:FindFirstChild('HumanoidRootPart')
    if not hrp then return end

    hrp.CFrame += hrp.CFrame.LookVector * quickTPPower.Value
end)
    
PhysicsTab:CreateDivider()

bigHead = PhysicsTab:CreateToggle({
    Name = 'Big Head Players',
    Default = false,
    Tip = 'Increases the size of other players heads.',
})

bigHeadSize = PhysicsTab:CreateSlider({
    Name = 'Big Head Size',
    Min = 1,
    Max = 6,
    Default = 1,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the size applied to player heads.',
})

task.spawn(function()
    while true do
        task.wait()

        for _, v in next, players:GetPlayers() do
            if v == player then continue end

            local character = v.Character
            if not character then continue end

            local head = character:FindFirstChild('Head')
            if not head then continue end

            head.Size = Vector3.new(bigHead.Value and bigHeadSize.Value or 1, bigHead.Value and bigHeadSize.Value or 1, bigHead.Value and bigHeadSize.Value or 1)
        end
    end
end)
    
local VisualTab = Window:CreateTab({ Name = 'Visual', Icon = 'rbxassetid://88610077537468' })

jumpSpot = VisualTab:CreateToggle({
    Name = 'Visualise Football Jump Spot',
    Default = false,
    Tip = 'Displays the predicted jump location of incoming footballs.',
})

workspace.ChildAdded:Connect(function(v)
    if not jumpSpot.Value then return end
    if not v:IsA('BasePart') or v.Name ~= 'Football' then return end

    task.wait()

    local position = v.Position
    local velocity = v.AssemblyLinearVelocity
    local gravity = Vector3.new(0, -28, 0)
    local deltaTime = 1 / 30

    local positions = {position}

    local raycastParams = RaycastParams.new()
    raycastParams.FilterType = Enum.RaycastFilterType.Exclude
    raycastParams.FilterDescendantsInstances = {v}
    raycastParams.IgnoreWater = true

    for _ = 1, 300 do
        local nextPosition = position + velocity * deltaTime + 0.5 * gravity * deltaTime ^ 2
        velocity += gravity * deltaTime

        if velocity.Y < 0 then
            local direction = nextPosition - position
            local result = workspace:Raycast(position, direction + Vector3.new(0, -14.4, 0), raycastParams)

            if result then
                nextPosition = result.Position
                table.insert(positions, nextPosition)
                break
            end
        end

        table.insert(positions, nextPosition)
        position = nextPosition
    end

    local optimalPoint = positions[#positions]
    
    local model = Instance.new('Model')
    model.Parent = workspace

    local baseY = optimalPoint.Y - 1.5
    local undergroundY = baseY - 6

    local gradientCylinder = Instance.new('MeshPart')
    gradientCylinder.MeshId = 'rbxassetid://8091779363'
    gradientCylinder.Material = Enum.Material.Plastic
    gradientCylinder.Size = Vector3.new(2, 4, 2)
    gradientCylinder.Rotation = Vector3.new(180, 0, 180)
    gradientCylinder.Transparency = 1
    gradientCylinder.Anchored = true
    gradientCylinder.CanCollide = false
    gradientCylinder.Position = Vector3.new(optimalPoint.X, undergroundY, optimalPoint.Z)
    gradientCylinder.Parent = model

    local faces = {
        Enum.NormalId.Front,
        Enum.NormalId.Back,
        Enum.NormalId.Left,
        Enum.NormalId.Right
    }

    for _, face in next, faces do
        local decal = Instance.new('Decal')
        decal.Face = face
        decal.Texture = 'rbxassetid://8097185954'
        decal.Transparency = 0
        decal.Color3 = Color3.fromRGB(255, 255, 255)
        decal.Parent = gradientCylinder
    end

    local glowCircle = Instance.new('MeshPart')
    glowCircle.MeshId = 'rbxassetid://8091848285'
    glowCircle.Material = Enum.Material.Neon
    glowCircle.Color = Color3.fromRGB(255, 255, 255)
    glowCircle.Size = Vector3.new(3.731, 0.031, 3.731)
    glowCircle.Rotation = Vector3.new(180, 0, 180)
    glowCircle.Transparency = 1
    glowCircle.Anchored = true
    glowCircle.CanCollide = false
    glowCircle.Position = Vector3.new(optimalPoint.X, undergroundY, optimalPoint.Z)
    glowCircle.Parent = model

    local emitter = Instance.new('ParticleEmitter')
    emitter.Texture = 'rbxasset://textures/particles/sparkles_main.dds'
    emitter.Rate = 5
    emitter.Speed = NumberRange.new(5, 5)
    emitter.Lifetime = NumberRange.new(0.5, 0.5)
    emitter.EmissionDirection = Enum.NormalId.Top
    emitter.TimeScale = 0.3
    emitter.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255))
    emitter.Parent = gradientCylinder

    local bottomPart = Instance.new('Part')
    bottomPart.Size = Vector3.new(0.311, 0.311, 0.311)
    bottomPart.Transparency = 1
    bottomPart.Material = Enum.Material.Plastic
    bottomPart.Anchored = true
    bottomPart.CanCollide = false
    bottomPart.Position = Vector3.new(optimalPoint.X, undergroundY, optimalPoint.Z)
    bottomPart.Parent = model

    local pointLight = Instance.new('PointLight')
    pointLight.Color = Color3.fromRGB(255, 255, 255)
    pointLight.Range = 12
    pointLight.Brightness = 2
    pointLight.Parent = bottomPart

    local tweenInfo = TweenInfo.new(0.55, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

    local upGoal = {
        Position = Vector3.new(optimalPoint.X, baseY, optimalPoint.Z)
    }

    local downGoal = {
        Position = Vector3.new(optimalPoint.X, undergroundY, optimalPoint.Z)
    }

    local upTweens = {
        tweenService:Create(gradientCylinder, tweenInfo, upGoal),
        tweenService:Create(glowCircle, tweenInfo, upGoal),
        tweenService:Create(bottomPart, tweenInfo, upGoal)
    }

    for _, t in next, upTweens do
        t:Play()
    end

    task.spawn(function()
        while v and v.Parent and v.AssemblyLinearVelocity.Magnitude > 1 do
            task.wait()
        end

        local downTweens = {
            tweenService:Create(gradientCylinder, tweenInfo, downGoal),
            tweenService:Create(glowCircle, tweenInfo, downGoal),
            tweenService:Create(bottomPart, tweenInfo, downGoal)
        }

        for _, t in next, downTweens do
            t:Play()
        end

        task.wait(0.4)

        if model.Parent then
            model:Destroy()
        end
    end)
end)
    
    throwSpot = VisualTab:CreateToggle({
    Name = 'Visualise Football Throw Spot',
    Default = false,
    Tip = 'Shows the predicted landing point of thrown footballs.',
})
    
    workspace.ChildAdded:Connect(function(v)
        if not throwSpot.Value then return end
    if not v:IsA('BasePart') or v.Name ~= 'Football' then return end

    task.wait()

    local pos = v.Position
    local vel = v.AssemblyLinearVelocity
    local gravity = Vector3.new(0, -28, 0)

    local positions = {}
    local parts = {}

    local dt = 0.05
    local maxTime = 8

    local lastPos = pos
    local spawnY = pos.Y

    for t = 0, maxTime, dt do
        local projectilePos = pos + (vel * t) + (0.5 * gravity * t * t)

        table.insert(positions, projectilePos)

        if projectilePos.Y < spawnY then
            break
        end

        local ray = workspace:Raycast(lastPos, projectilePos - lastPos)
        if ray then
            positions[#positions] = ray.Position
            break
        end

        lastPos = projectilePos
    end

    local endPos = positions[#positions]
    if not endPos then return end

    local posPart = Instance.new('Part', workspace.Terrain)
    posPart.Anchored = true
    posPart.CanCollide = false
    posPart.CastShadow = false
    posPart.Size = Vector3.new(3, 3, 3)
    posPart.Shape = Enum.PartType.Ball
    posPart.Color = Color3.fromRGB(0, 0, 0)
    posPart.Position = endPos

    for i = 1, #positions - 1 do
        local p0 = positions[i]
        local p1 = positions[i + 1]

        local beamPart = Instance.new('Part', workspace.Terrain)
        beamPart.Anchored = true
        beamPart.CanCollide = false
        beamPart.CastShadow = false
        beamPart.Material = Enum.Material.Neon
        beamPart.Color = Color3.fromRGB(255, 255, 255)

        local dist = (p1 - p0).Magnitude

        beamPart.Size = Vector3.new(0.4, 0.4, dist)
        beamPart.CFrame = CFrame.lookAt((p0 + p1) / 2, p1)

        table.insert(parts, beamPart)
    end

    task.spawn(function()
        local speed = math.max(vel.Magnitude, 1)
        local delayTime = math.clamp(300 / speed, 0.01, 0.04)

        for _, part in next, parts do
            task.wait(delayTime)

            if part.Parent then
                part:Destroy()
            end
        end

        if posPart.Parent then
            posPart:Destroy()
        end
    end)
end)
    
VisualTab:CreateDivider()
    
enableGloves = VisualTab:CreateToggle({
    Name = 'Enable Uniform Gloves',
    Default = true,
    Tip = 'Toggles visibility of uniform gloves.',
})

task.spawn(function()
    while true do
        task.wait()

        local character = player.Character
        if not character then continue end

        local uniform = character:FindFirstChild('Uniform')
        if not uniform then continue end

        local gloveVisible

        for _, v in next, uniform:GetDescendants() do
            if not v:IsA('BasePart') then continue end
            if not v.Name:lower():find('glove') then continue end

            gloveVisible = v.Transparency == 0
            break
        end

        if gloveVisible == nil then continue end

        if enableGloves.Value and not gloveVisible then
            replicatedStorage.Remotes.CharacterSoundEvent:FireServer('Game', 'Customization', 'Toggle', 'LeftGlove')
            replicatedStorage.Remotes.CharacterSoundEvent:FireServer('Game', 'Customization', 'Toggle', 'RightGlove')
        elseif not enableGloves.Value and gloveVisible then
            replicatedStorage.Remotes.CharacterSoundEvent:FireServer('Game', 'Customization', 'Toggle', 'LeftGlove')
            replicatedStorage.Remotes.CharacterSoundEvent:FireServer('Game', 'Customization', 'Toggle', 'RightGlove')
        end
    end
end)

VisualTab:CreateDivider()
    
noBallTrail = VisualTab:CreateToggle({
    Name = 'No Ball Trail',
    Default = false,
    Tip = 'Removes football trail effects.',
})

workspace.ChildAdded:Connect(function(v)
    if not noBallTrail.Value then return end

    if v:IsA('BasePart') and v.Name == 'Football' then
        local trail = v:FindFirstChildOfClass('Trail')
        if trail then
            trail:Destroy()
        end
    end
end)

local stadiumParts = {}

for _, v in next, workspace.Models.Stadium:GetDescendants() do
    if not v:IsA('BasePart') then continue end

    stadiumParts[#stadiumParts + 1] = {
        Part = v,
        Transparency = v.Transparency,
        CanCollide = v.CanCollide
    }
end

hideStadium = VisualTab:CreateToggle({
    Name = 'Hide Stadium',
    Default = false,
    Tip = 'Hides visible stadium structures.',
    Callback = function(v)
        for _, p in next, stadiumParts do
            p.Part.Transparency = v and 1 or p.Transparency
            p.Part.CanCollide = v and false or p.CanCollide
        end
    end
})

VisualTab:CreateDivider()

local lighting = game:GetService('Lighting')

local function ApplySkyBox(name)
    for _, v in next, lighting:GetChildren() do
        if v:IsA("Sky") or v:IsA("PostEffect") or v:IsA("Atmosphere") then
            v:Destroy()
        end
    end

    if name == "Golden Twilight" then
        local Sky = Instance.new("Sky")
        Sky.Name = name
        Sky.Parent = lighting
        Sky.SkyboxBk = "rbxassetid://541743453"
        Sky.SkyboxDn = "rbxassetid://541743443"
        Sky.SkyboxFt = "rbxassetid://541743446"
        Sky.SkyboxLf = "rbxassetid://541743436"
        Sky.SkyboxRt = "rbxassetid://541743435"
        Sky.SkyboxUp = "rbxassetid://541743441"

    elseif name == "Infernal Horizon" then
        local Sky = Instance.new("Sky")
        Sky.Name = name
        Sky.Parent = lighting
        Sky.SkyboxBk = "http://www.roblox.com/asset/?id=169210090"
        Sky.SkyboxDn = "http://www.roblox.com/asset/?id=169210108"
        Sky.SkyboxFt = "http://www.roblox.com/asset/?id=169210121"
        Sky.SkyboxLf = "http://www.roblox.com/asset/?id=169210133"
        Sky.SkyboxRt = "http://www.roblox.com/asset/?id=169210143"
        Sky.SkyboxUp = "http://www.roblox.com/asset/?id=169210149"
        Sky.StarCount = 100
        Sky.SunTextureId = " "

        local BlurEffect = Instance.new("BlurEffect")
        BlurEffect.Parent = lighting
        BlurEffect.Size = 6

        local ColorCorrectionEffect = Instance.new("ColorCorrectionEffect")
        ColorCorrectionEffect.Parent = lighting
        ColorCorrectionEffect.Brightness = 0.01
        ColorCorrectionEffect.Contrast = 0.15
        ColorCorrectionEffect.Saturation = 0.4
        ColorCorrectionEffect.TintColor = Color3.new(0.815686, 0.776471, 0.690196)

    elseif name == "Nebula Peaks" then
        local Sky = Instance.new("Sky")
        Sky.Name = name
        Sky.Parent = lighting
        Sky.CelestialBodiesShown = false
        Sky.SkyboxBk = "http://www.roblox.com/asset/?id=17124357467"
        Sky.SkyboxDn = "http://www.roblox.com/asset/?id=17124359797"
        Sky.SkyboxFt = "http://www.roblox.com/asset/?id=17124362093"
        Sky.SkyboxLf = "http://www.roblox.com/asset/?id=17124365127"
        Sky.SkyboxRt = "http://www.roblox.com/asset/?id=17124367200"
        Sky.SkyboxUp = "http://www.roblox.com/asset/?id=17124369657"

        local cc = Instance.new("ColorCorrectionEffect")
        cc.Parent = lighting
        cc.Brightness = 0.1
        cc.Contrast = 0.3
        cc.Saturation = 0.2
        cc.TintColor = Color3.fromRGB(140, 190, 255)

        local bloom = Instance.new("BloomEffect")
        bloom.Parent = lighting
        bloom.Intensity = 1.2
        bloom.Threshold = 0.8
        bloom.Size = 56

        local atmosphere = Instance.new("Atmosphere")
        atmosphere.Parent = lighting
        atmosphere.Density = 0.25
        atmosphere.Offset = 0.2
        atmosphere.Glare = 0.3
        atmosphere.Haze = 1
        atmosphere.Color = Color3.fromRGB(80, 110, 150)
        atmosphere.Decay = Color3.fromRGB(25, 30, 35)

    elseif name == "Rose Glow" then
        local Sky = Instance.new("Sky")
        Sky.Name = name
        Sky.Parent = lighting
        Sky.CelestialBodiesShown = false
        Sky.SkyboxBk = "http://www.roblox.com/asset/?id=109305193"
        Sky.SkyboxDn = "http://www.roblox.com/asset?id=58372722"
        Sky.SkyboxFt = "http://www.roblox.com/asset/?id=109305200"
        Sky.SkyboxLf = "http://www.roblox.com/asset/?id=109305185"
        Sky.SkyboxRt = "http://www.roblox.com/asset/?id=109305189"
        Sky.SkyboxUp = "http://www.roblox.com/asset/?id=109305207"

    elseif name == "Night Sky" then
        local Sky = Instance.new("Sky")
        Sky.Name = name
        Sky.Parent = lighting
        Sky.CelestialBodiesShown = false
        Sky.SkyboxBk = "http://www.roblox.com/Asset/?ID=12064107"
        Sky.SkyboxDn = "http://www.roblox.com/Asset/?ID=12064152"
        Sky.SkyboxFt = "http://www.roblox.com/Asset/?ID=12064121"
        Sky.SkyboxLf = "http://www.roblox.com/Asset/?ID=12063984"
        Sky.SkyboxRt = "http://www.roblox.com/Asset/?ID=12064115"
        Sky.SkyboxUp = "http://www.roblox.com/Asset/?ID=12064131"
        Sky.StarCount = 0

    elseif name == "Northern Lights" then
        local Sky = Instance.new("Sky")
        Sky.Name = name
        Sky.Parent = lighting
        Sky.CelestialBodiesShown = false
        Sky.SkyboxBk = "http://www.roblox.com/asset/?id=16563478983"
        Sky.SkyboxDn = "http://www.roblox.com/asset/?id=16563481302"
        Sky.SkyboxFt = "http://www.roblox.com/asset/?id=16563484084"
        Sky.SkyboxLf = "http://www.roblox.com/asset/?id=16563485362"
        Sky.SkyboxRt = "http://www.roblox.com/asset/?id=16563487078"
        Sky.SkyboxUp = "http://www.roblox.com/asset/?id=16563489821"
    end
end

local skyNames = {'Golden Twilight', 'Infernal Horizon', 'Nebula Peaks', 'Rose Glow', 'Night Sky', 'Northern Lights'}

for _, skyName in next, skyNames do
    VisualTab:CreateButton({
        Name = skyName,
        Tip = 'Applies the ' .. skyName .. ' skybox.',
        Callback = function()
            ApplySkyBox(skyName)
        end
    })
end

local DefenseTab = Window:CreateTab({ Name = 'Defense', Icon = 'rbxassetid://14939023862' })

swatReach = DefenseTab:CreateToggle({
    Name = 'Swat Reach',
    Default = false,
    Tip = 'Extends swat range on nearby footballs.',
})

swatReachDistance = DefenseTab:CreateSlider({
    Name = 'Swat Reach Radius',
    Min = 0,
    Max = 25,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the maximum swat distance.',
})

task.spawn(function()
    while true do
        task.wait()

        if not swatReach.Value then continue end

        local character = player.Character
        if not character then continue end

        local ball = findClosestBall()
        if not ball then continue end

        for _, v in next, character:GetChildren() do
            if v:IsA('BasePart') and v.Name:lower():find('catch') then
                local distance = (ball.Position - v.Position).Magnitude
                if distance < swatReachDistance.Value then
                    if v.Size.X > 2 then
                        firetouchinterest(v, ball, 0)
                        firetouchinterest(v, ball, 1)
                    end
                end
            end
        end
    end
end)

DefenseTab:CreateDivider()

tackleReach = DefenseTab:CreateToggle({
    Name = 'Extend Tackle Reach',
    Default = false,
    Tip = 'Extends tackle range against ball carriers.',
})

tackleAimbot = DefenseTab:CreateToggle({
    Name = 'Tackle Aimbot',
    Default = false,
    Tip = 'Automatically targets nearby ball carriers.',
})

tackleAimbotRange = DefenseTab:CreateSlider({
    Name = 'Tackle Aimbot Distance',
    Min = 0,
    Max = 25,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the maximum targeting distance.',
})

task.spawn(function()
    while true do
        task.wait()

        local character = player.Character
        if not character then continue end

        if tackleReach.Value then
            for _, v in next, players:GetPlayers() do
                if v ~= player and v.Team ~= player.Team and v.Character and v.Character:FindFirstChild('Football') then
                    local bodyParts = {'Torso', 'Head', 'HumanoidRootPart', 'Left Arm', 'Left Leg', 'Right Arm', 'Right Leg'}
                    local randomPart = bodyParts[math.random(1, #bodyParts)]

                    replicatedStorage.Remotes.CharacterSoundEvent:FireServer('Game', 'TackleTouch', randomPart, randomPart)
                end
            end
        end

        if tackleAimbot.Value then
            for _, v in next, players:GetPlayers() do
                if v ~= player and v.Team ~= player.Team and v.Character and v.Character.Humanoid.WalkSpeed > 0 and v.Character:FindFirstChild('Football') then
                    local distance = (v.Character.HumanoidRootPart.Position - character.HumanoidRootPart.Position).Magnitude
                    if distance < tackleAimbotRange.Value then
                        character.HumanoidRootPart.CFrame = v.Character.HumanoidRootPart.CFrame
                        character.HumanoidRootPart.CFrame = v.Character.HumanoidRootPart.CFrame
                    end
                end
            end
        end
    end
end)

local AutomaticsTab = Window:CreateTab({ Name = 'Automatics', Icon = 'rbxassetid://86084882582277' })

autoRush = AutomaticsTab:CreateToggle({
    Name = 'Auto Rush',
    Default = false,
    Tip = 'Automatically moves toward the opposing ball carrier in range.',
})

walkToLine = AutomaticsTab:CreateToggle({
    Name = 'Walk To Line',
    Default = false,
    Tip = 'Moves the player to the line before play starts.',
})

autoRushReactionTime = AutomaticsTab:CreateSlider({
    Name = 'Reaction Time',
    Min = 0,
    Max = 1,
    Default = 0.15,
    Increment = 0.01,
    Suffix = '',
    Tip = 'Adjusts how quickly the feature responds.',
})

task.spawn(function()
    while true do
        task.wait()

        if not autoRush.Value then continue end

        local character = player.Character
        if not character then continue end

        local humanoid = character:FindFirstChildOfClass('Humanoid')
        if not humanoid then continue end

        local hrp = character:FindFirstChild('HumanoidRootPart')
        if not hrp then continue end

        if walkToLine.Value then
            if replicatedStorage:FindFirstChild('Flags')
                and replicatedStorage.Flags:FindFirstChild('PossessionTag')
                and replicatedStorage.Flags:FindFirstChild('Status')
                and replicatedStorage.Flags.PossessionTag.Value ~= player.Team.Name
                and replicatedStorage.Flags.Status.Value == 'PrePlay' then

                local line = workspace:FindFirstChild('LineDown')
                if line then
                    humanoid:MoveTo(line.Position)
                end
            end
        end

        for _, v in next, players:GetPlayers() do
            if v == player then continue end
            if v.Team == player.Team then continue end
            if not v.Character then continue end

            local enemyChar = v.Character
            local enemyHumanoid = enemyChar:FindFirstChildOfClass('Humanoid')
            local enemyHrp = enemyChar:FindFirstChild('HumanoidRootPart')
            if not enemyHumanoid or not enemyHrp then continue end

            local football = enemyChar:FindFirstChild('Football')
            if not football then continue end

            local footballPart = football:FindFirstChildWhichIsA('BasePart')
            if not footballPart then continue end

            if enemyHumanoid.WalkSpeed <= 0 then continue end
            if enemyHumanoid.PlatformStand then continue end

            local ping = 0
            if stats and stats:FindFirstChild('Network') 
                and stats.Network:FindFirstChild('ServerStatsItem')
                and stats.Network.ServerStatsItem:FindFirstChild('Data Ping') then
                ping = stats.Network.ServerStatsItem['Data Ping']:GetValue() / 1000
            end

            local speed = enemyHumanoid.MoveDirection.Magnitude > 0 and enemyHumanoid.WalkSpeed or 0
            local predictionTime = ping + autoRushReactionTime.Value

            local pos = footballPart.Position + (enemyHumanoid.MoveDirection * speed * predictionTime * 20)

            local direction = pos - enemyHrp.Position
            if direction.Magnitude > 0 then
                pos += direction.Unit * ((hrp.Position - pos).Magnitude / 20)
            end

            humanoid:MoveTo(pos)
        end
    end
end)

AutomaticsTab:CreateDivider()

autoCatch = AutomaticsTab:CreateToggle({
    Name = 'Auto Catch',
    Default = false,
    Tip = 'Automatically moves toward nearby catch opportunities.',
})

autoCatchRadius = AutomaticsTab:CreateSlider({
    Name = 'Auto Catch Distance',
    Min = 0,
    Max = 25,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets how far the auto catch detection can reach.',
})
    
AutomaticsTab:CreateDivider()

autoSwat = AutomaticsTab:CreateToggle({
    Name = 'Auto Swat',
    Default = false,
    Tip = 'Automatically reacts to nearby incoming balls.',
})

autoSwatRadius = AutomaticsTab:CreateSlider({
    Name = 'Auto Swat Distance',
    Min = 0,
    Max = 25,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets how far the auto swat detection can reach.',
})

task.spawn(function()
    while true do
        task.wait()

        if not autoCatch.Value and not autoSwat.Value then continue end

        local character = player.Character
        if not character then continue end

        local humanoidRootPart = character:FindFirstChild('HumanoidRootPart')
        if not humanoidRootPart then continue end

        local ball = findClosestBall()
        if not ball then continue end

        local distance = (ball.Position - humanoidRootPart.Position).Magnitude

        if autoCatch.Value and distance <= autoCatchRadius.Value then
            replicatedStorage.Remotes.CharacterSoundEvent:FireServer('PlayerActions', isPractice and 'catch ' or 'catch')
        end

        if autoSwat.Value and distance <= autoSwatRadius.Value then
            replicatedStorage.Remotes.CharacterSoundEvent:FireServer('PlayerActions', 'swat')
        end
    end
end)
    
AutomaticsTab:CreateDivider()
    
autoCaptain = AutomaticsTab:CreateToggle({
    Name = 'Auto Win Captain',
    Default = false,
    Tip = 'Automatically moves toward the finish line during captain selection.',
})

task.spawn(function()
    while true do
        task.wait()

        if not autoCaptain.Value then continue end

        local character = player.Character
        if not character then continue end

        local hrp = character:FindFirstChild('HumanoidRootPart')
        if not hrp then continue end

        for _, v in next, workspace.Models.LockerRoomA:GetChildren() do
            if v.Name:lower():find('finishline') and not player.Team then
                v:GetPropertyChangedSignal('CFrame'):Connect(function()
                    for i = 1, 4 do
                        task.wait()

                        hrp.CFrame = v.CFrame
                    end
                end)
            end
        end
    end
end)
    
AutomaticsTab:CreateDivider()
    
autoFreeze = AutomaticsTab:CreateToggle({
    Name = 'Auto Freeze',
    Default = false,
    Tip = 'Temporarily anchors your character on input.',
})

freezeDuration = AutomaticsTab:CreateSlider({
    Name = 'Freeze Duration',
    Min = 0,
    Max = 3,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Duration the freeze state lasts.',
})

freezeKeybind = AutomaticsTab:CreateKeybind({
    Name = 'Freeze Keybind',
    Default = nil,
    Tip = 'Key used to trigger freeze.',
})

userInputService.InputBegan:Connect(function(input)
    if not autoFreeze.Value then return end
    if freezeKeybind.Value and input.KeyCode ~= freezeKeybind.Value then return end

    local character = player.Character
    if not character then return end

    local hrp = character:FindFirstChild('HumanoidRootPart')
    if not hrp then return end

    hrp.Anchored = true

    task.delay(freezeDuration.Value, function()
        if hrp then
            hrp.Anchored = false
        end
    end)
end)

AutomaticsTab:CreateDivider()

autoQb = AutomaticsTab:CreateToggle({
    Name = 'Auto QB',
    Default = false,
    Tip = 'Automatically positions your character for quarterback play.',
})

autoQbMethod = AutomaticsTab:CreateDropdown({
    Name = 'Auto QB Method',
    Options = {'Walk', 'Teleport'},
    Default = 'Walk',
    Tip = 'Selects how automatic positioning is performed.',
})

task.spawn(function()
    while true do
        task.wait()

        if not autoQb.Value then continue end

        local character = player.Character
        if not character then continue end

        local humanoid = character:FindFirstChildOfClass('Humanoid')
        local humanoidRootPart = character:FindFirstChild('HumanoidRootPart')
        if not humanoid or not humanoidRootPart then continue end

        local ball = findClosestBall()
        if not ball then continue end

        if replicatedStorage:FindFirstChild('Flags')
            and replicatedStorage.Flags:FindFirstChild('PossessionTag')
            and replicatedStorage.Flags:FindFirstChild('Status')
            and replicatedStorage.Flags.PossessionTag.Value == player.Team.Name
            and replicatedStorage.Flags.Status.Value == 'PrePlay' then

            if autoQbMethod.Value == 'Walk' then
                humanoid:MoveTo(ball.Position)
            elseif autoQbMethod.Value == 'Teleport' then
                humanoidRootPart.CFrame = ball.CFrame
            end
        else
            pcall(function()
                ball.CFrame = humanoidRootPart.CFrame
            end)
        end
    end
end)
    
AutomaticsTab:CreateDivider()
    
    autoBoost = AutomaticsTab:CreateToggle({
    Name = 'Auto Boost',
    Default = false,
    Tip = 'Automatically assists aerial movement near incoming footballs.',
})

targetClosestPlayer = AutomaticsTab:CreateToggle({
    Name = 'Target Player Closer To The Ball',
    Default = false,
    Tip = 'Prioritizes players closest to the football.',
})

boostStrength = AutomaticsTab:CreateSlider({
    Name = 'Boost Strength',
    Min = 0,
    Max = 3,
    Default = 1.5,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Adjusts the strength of the boost effect.',
})

boostRadius = AutomaticsTab:CreateSlider({
    Name = 'Boost Radius',
    Min = 0,
    Max = 15,
    Default = 0,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Sets the activation distance for boosting.',
})

boostPower = AutomaticsTab:CreateSlider({
    Name = 'Boost Power',
    Min = 50,
    Max = 70,
    Default = 50,
    Increment = 0.1,
    Suffix = '',
    Tip = 'Controls the upward force applied during a boost.',
})

task.spawn(function()
    local activeTween

    while true do
        task.wait()

        if not autoBoost.Value then
            if activeTween then
                activeTween:Cancel()
                activeTween = nil
            end

            continue
        end

        local char = player.Character
        if not char then continue end

        local hum = char:FindFirstChildOfClass('Humanoid')
        if not hum then continue end

        local hrp = char:FindFirstChild('HumanoidRootPart')
        if not hrp then continue end

        if hum:GetState() == Enum.HumanoidStateType.Landed then
            if activeTween then
                activeTween:Cancel()
                activeTween = nil
            end

            continue
        end

        local myHead = char:FindFirstChild('Head')
        if not myHead then continue end

        local targetPlayer

        if targetClosestPlayer.Value then
            local nearestBall
            local nearestBallDist = math.huge

            for _, ball in next, workspace:GetChildren() do
                if not ball:IsA('BasePart') then continue end
                if not ball.Name:lower():find('ball') then continue end

                local dist = (ball.Position - myHead.Position).Magnitude

                if dist < nearestBallDist then
                    nearestBallDist = dist
                    nearestBall = ball
                end
            end

            if not nearestBall then continue end

            local closestDist = math.huge

            for _, v in next, players:GetPlayers() do
                if v == player then continue end

                local character = v.Character
                if not character then continue end

                local head = character:FindFirstChild('Head')
                if not head then continue end

                local dist = (head.Position - nearestBall.Position).Magnitude

                if dist < closestDist then
                    closestDist = dist
                    targetPlayer = v
                end
            end
        else
            local closestDist = math.huge

            for _, v in next, players:GetPlayers() do
                if v == player then continue end

                local character = v.Character
                if not character then continue end

                local head = character:FindFirstChild('Head')
                if not head then continue end

                local dist = (head.Position - myHead.Position).Magnitude

                if dist < closestDist then
                    closestDist = dist
                    targetPlayer = v
                end
            end
        end

        if not targetPlayer then continue end

        local character = targetPlayer.Character
        if not character then continue end

        local head = character:FindFirstChild('Head')
        if not head then continue end

        local targetHumanoid = character:FindFirstChildOfClass('Humanoid')
        if not targetHumanoid then continue end

        local myState = hum:GetState()
        local targetState = targetHumanoid:GetState()

        local distance = (head.Position - myHead.Position).Magnitude

        if distance > boostRadius.Value then
            continue
        end

        if myState ~= Enum.HumanoidStateType.Jumping
            and myState ~= Enum.HumanoidStateType.Freefall then
            continue
        end

        if targetState ~= Enum.HumanoidStateType.Jumping
            and targetState ~= Enum.HumanoidStateType.Freefall then
            continue
        end

        local speed = math.max(hum.WalkSpeed * boostStrength.Value, 1)
        local targetPos = head.Position

        local duration = math.max((hrp.Position - targetPos).Magnitude / speed, 0.01)

        if activeTween then
            activeTween:Cancel()
        end

        activeTween = tweenService:Create(
            hrp,
            TweenInfo.new(duration, Enum.EasingStyle.Linear),
            {
                CFrame = CFrame.new(targetPos)
            }
        )

        activeTween:Play()

        activeTween.Completed:Once(function(state)
            if state ~= Enum.PlaybackState.Completed then
                return
            end

            hrp.AssemblyLinearVelocity = Vector3.new(
                hrp.AssemblyLinearVelocity.X,
                boostPower.Value,
                hrp.AssemblyLinearVelocity.Z
            )
        end)
    end
end)

local MiscTab = Window:CreateTab({ Name = 'Misc', Icon = 'rbxassetid://129082556946713' })

fpsCap = MiscTab:CreateSlider({
    Name = 'Uncap FPS Amount',
    Min = 30,
    Max = 240,
    Default = 240,
    Increment = 1,
    Suffix = '',
    Tip = 'Sets the maximum FPS limit.',
})

task.spawn(function()
    while true do
        task.wait()

        setfpscap(fpsCap.Value)
    end
end)

antiAdmin = MiscTab:CreateToggle({
    Name = 'Anti Admin',
    Default = false,
    Tip = 'Automatically reacts when administrators are detected.',
    Keybind = nil,
})

task.spawn(function()
    while task.wait() do
        local playerGui = player:FindFirstChild("PlayerGui")
        if not playerGui then continue end
        
        local miscText = playerGui:FindFirstChild("MiscText")
        if not miscText then continue end
        
        local isVIP = miscText:FindFirstChild("IsVIP")
        if not isVIP then continue end
        
        if isVIP.Visible == true then continue end
        
        for _, admin in next, players:GetPlayers() do
            if admin == player then continue end
            
            local swagData = admin:FindFirstChild("SwagData")
            if not swagData then continue end
            
            local adminTag = swagData:FindFirstChild("Admin")
            if not adminTag then continue end
            
            if adminTag.Value ~= "" and antiAdmin.Value then
                player:Kick("[Cheeto Hub] Detected Admin\
Name: " .. admin.Name .. "\
ID: " .. admin.UserId)
            end
        end
    end
end)

smoothReplay = MiscTab:CreateToggle({
		Name = 'Smooth Replay',
		Default = false,
		Tip = 'Smooths replay playback for improved visual quality.',
		Keybind = nil,
	})

	replayFPS = MiscTab:CreateSlider({
		Name = 'Replay Frame Per Second',
		Min = 9,
		Max = 120,
		Default = 9,
		Increment = 1,
		Tip = 'Sets the replay playback frame rate.',
	})
    
if not isPractice then

	local player = game:GetService('Players').LocalPlayer
	local replicatedStorage = game:GetService('ReplicatedStorage')
	local runService = game:GetService('RunService')

	local remote = replicatedStorage:WaitForChild('Remotes'):WaitForChild('CharacterSoundEvent')
	local heartbeat = runService.Heartbeat

	local transition = player:WaitForChild('PlayerGui'):WaitForChild('MainGui'):WaitForChild('Transition')

	local homeCamera = CFrame.Angles(-0.2617993877991494, 0, 0)
	local awayCamera = CFrame.Angles(0.2617993877991494, math.pi, 0)

	local cameraOffset = CFrame.new(0, 0, 19)

	local limbs = {
		'Torso',
		'Left Arm',
		'Right Arm',
		'Left Leg',
		'Right Leg',
		'Head'
	}

	task.spawn(function()
		while true do
			task.wait()

			local replayScript = player.PlayerScripts:FindFirstChild('ClientReplay')
			if replayScript then
				replayScript.Enabled = not smoothReplay.Value
			end
		end
	end)

	local replay = function(data, characters)
		local replayBall = workspace:WaitForChild('ReplayBall')
		local camera = workspace.CurrentCamera

		camera.CameraType = Enum.CameraType.Scriptable
		camera.CameraSubject = replayBall

		local cameraRotation = data.changes[1].poss == 'h' and homeCamera or awayCamera

		local currentChange = 1
		local highestY = 18
		local cameraTilt = true

		local playback = 1
		local recordedFPS = data.fps

		local accumulator = 0
		local last = tick()

		local getFrame = function(index)
			local maxFrames = #data.ball
			if index < 1 then return 1 end
			if index > maxFrames then return maxFrames end
			return index
		end

		local interpolate = function(a, b, alpha)
			return a:Lerp(b, alpha)
		end

		while playback < #data.ball do
			if replicatedStorage.Flags.StatusTag.Value ~= 'REPLAY' then
				break
			end

			if camera.CameraType ~= Enum.CameraType.Scriptable then
				break
			end

			local replayFPSValue = replayFPS.Value
			local replayDelta = 1 / replayFPSValue

			local now = tick()
			accumulator += now - last
			last = now

			while accumulator >= replayDelta do
				playback += recordedFPS / replayFPSValue
				accumulator -= replayDelta
			end

			local frame1 = getFrame(math.floor(playback))
			local frame2 = getFrame(math.ceil(playback))
			local alpha = playback - frame1

			for _, character in next, characters do
				local characterData = data.limbs[character.Name]
				if not characterData then character.Parent = nil continue end

				local limbData = characterData[1]
				local accessoryData = characterData[2]

				if not limbData[1] then
					character.Parent = nil
					continue
				end

				local torso1 = limbData[1][2][frame1]
				local torso2 = limbData[1][2][frame2]

				if not torso1 or not torso2 then
					character.Parent = nil
					continue
				end

				local torso = interpolate(torso1, torso2, alpha)

				for i = 1, #limbs do
					local limbName = limbs[i]
					local limb = character:FindFirstChild(limbName)
					if not limb then continue end

					local replayLimb = limbData[i]
					if not replayLimb then continue end

					local cf1 = replayLimb[2][frame1]
					local cf2 = replayLimb[2][frame2]

					if i == 4 then
						if cf1 and cf2 then
							local angle = cf1 + ((cf2 - cf1) * alpha)

							limb.CFrame =
								torso *
								CFrame.new(-0.5, -1, 0) *
								CFrame.fromOrientation(angle, 0, 0) *
								CFrame.new(0, -1, 0)
						end
					elseif i == 5 then
						if cf1 and cf2 then
							local angle = cf1 + ((cf2 - cf1) * alpha)

							limb.CFrame =
								torso *
								CFrame.new(0.5, -1, 0) *
								CFrame.fromOrientation(angle, 0, 0) *
								CFrame.new(0, -1, 0)
						end
					else
						if cf1 and cf2 then
							limb.CFrame = interpolate(cf1, cf2, alpha)
						elseif i == 6 then
							limb.CFrame = torso * CFrame.new(0, 1.5, 0)
						end
					end
				end

				local uniform = character:FindFirstChild('Uniform')
				if accessoryData and uniform then
					for name, info in next, accessoryData do
						if uniform:FindFirstChild(name) and character:FindFirstChild(info[1]) then
							uniform[name].CFrame =
								character[info[1]].CFrame * info[2]
						end
					end
				end
			end

			local ball1 = data.ball[frame1]
			local ball2 = data.ball[frame2]

			if ball1 and ball2 then
				replayBall.CFrame = interpolate(ball1, ball2, alpha)
			end

			if highestY < replayBall.Position.Y then
				highestY = replayBall.Position.Y
			elseif highestY > 49 and cameraTilt then
				local x = select(1, cameraRotation:ToOrientation())

				cameraRotation *= CFrame.Angles(
					x * 3 * math.clamp((highestY - 50) / 99, 0, 1),
					0,
					0
				)

				cameraTilt = false
			end

			local targetCamera

			if highestY > 49 and cameraTilt then
				local x = select(1, cameraRotation:ToOrientation())

				targetCamera =
					CFrame.new(replayBall.Position) *
					cameraRotation *
					CFrame.Angles(
						x * 3 * math.clamp((highestY - 50) / 99, 0, 1),
						0,
						0
					) *
					cameraOffset
			else
				targetCamera =
					CFrame.new(replayBall.Position) *
					cameraRotation *
					cameraOffset
			end

			camera.CFrame = targetCamera

			local change = data.changes[currentChange]

			if change and change.frame <= frame1 then
				currentChange += 1

				if change.frame == frame1 then
					if change.poss and (frame1 > 9 and (change.turnover or highestY > 49)) then
						local nextRotation =
							change.poss == 'h' and homeCamera or awayCamera

						local duration =
							(change.turnover == true or replayBall.Position.Y >= 13)
							and 0.5
							or (highestY / 500)

						local elapsed = 0
						local startRotation = cameraRotation

						while elapsed < duration do
							elapsed += heartbeat:Wait()

							cameraRotation = startRotation:Lerp(
								nextRotation,
								math.clamp(elapsed / duration, 0, 1)
							)

							camera.CFrame =
								CFrame.new(replayBall.Position) *
								cameraRotation *
								cameraOffset
						end

						cameraRotation = nextRotation

					elseif change.freeze then
						task.wait(change.freeze)
					end
				end
			end

			heartbeat:Wait()
		end

		remote:FireServer('ReplayFinished')

		if replicatedStorage.Flags.StatusTag.Value == 'REPLAY' then
			replicatedStorage.Flags.StatusTag.Value = ''
		end

		task.wait(0.2)

		replayBall:Destroy()

		for _, character in next, characters do
			character:Destroy()
		end

		data.t = nil
		data.limbs = nil
		data.ball = nil

		camera.CameraType = Enum.CameraType.Custom
		camera.CameraSubject = player.Character.Humanoid
	end

	remote.OnClientEvent:Connect(function(action, ...)
		if action == 'ClientReplay' then
			while transition.Position.X.Scale > -2 and transition.Position.X.Scale < -0.5 do
				task.wait()
			end

			replay(...)
		end
	end)

end

Features & Information

Quarterback Aimbot Ball Magnets Angle Enhancer
#FF#Ff#football fusion

Community Comments (0)

No comments yet for this script.

More Scripts for Football Fusion 3