Quick actions

cmd+k|ctrl+k

Navigation

Languages

Cube Combination Utility v2

Snippet info

Language

Lua

Visibility

public

Author

panickyhospital950

Created

2026-04-04T05:38:17.657341Z

Updated

2026-04-04T05:38:17.657341Z

--[[
    CUBE COMBINATION UTILITY v2 | Xray + Inf Jump + Fullbright + Speed + Noclip + Fly + AC Nuker
    Game: https://www.roblox.com/games/9798463281/Cube-Combination
    
    Features:
      [1] Xray           - See through all solid parts
      [2] Infinite Jump   - Jump in mid-air unlimited times
      [3] Fullbright      - Remove darkness/fog
      [4] Speed Boost     - Advanced speed with CFrame movement, anti-detect
      [5] Noclip          - Phase through everything, raycast-based collision skip
      [6] Fly             - Advanced fly with smooth acceleration, sprint, freelook
      [7] Anti-AFK        - Prevent idle kick
      [8] AC Nuker        - Deep multi-layer anticheat destroyer
      
    UI: Toggle menu (press RightAlt or tap mobile button)
]]

------------------------------------------------------------------------
-- CLEANUP
------------------------------------------------------------------------
pcall(function()
    for _, g in pairs(game:GetService("Players").LocalPlayer.PlayerGui:GetChildren()) do
        if g.Name == "CCUtilGui_v2" then g:Destroy() end
    end
end)
pcall(function()
    if _G._CCv2Conns then
        for _, c in pairs(_G._CCv2Conns) do pcall(function() c:Disconnect() end) end
    end
end)
_G._CCv2Conns = {}
local function conn(c) table.insert(_G._CCv2Conns, c) return c end

------------------------------------------------------------------------
-- SERVICES
------------------------------------------------------------------------
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local TS = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
local Workspace = game:GetService("Workspace")
local LP = Players.LocalPlayer
local Mouse = LP:GetMouse()
local Camera = Workspace.CurrentCamera

local char, hmn, hrp
local function grab()
    char = LP.Character
    if not char then return false end
    hmn = char:FindFirstChildOfClass("Humanoid")
    hrp = char:FindFirstChild("HumanoidRootPart")
    return hrp ~= nil and hmn ~= nil
end
grab()
conn(LP.CharacterAdded:Connect(function(c)
    c:WaitForChild("HumanoidRootPart")
    task.wait(0.3)
    grab()
end))

------------------------------------------------------------------------
-- STATE
------------------------------------------------------------------------
local State = {
    xray = false,
    infJump = false,
    fullbright = false,
    speed = false,
    noclip = false,
    antiAfk = true,
    acNuker = false,
    fly = false,
}

local speedValue = 50
local flySpeed = 80
local flySprint = 200
local menuOpen = true
local originalTransparency = {}
local originalLighting = {}

------------------------------------------------------------------------
-- COLORS
------------------------------------------------------------------------
local C = {
    bg      = Color3.fromRGB(18, 18, 28),
    panel   = Color3.fromRGB(28, 28, 42),
    header  = Color3.fromRGB(35, 25, 60),
    accent  = Color3.fromRGB(130, 80, 255),
    accent2 = Color3.fromRGB(80, 200, 255),
    green   = Color3.fromRGB(50, 255, 100),
    red     = Color3.fromRGB(255, 60, 60),
    orange  = Color3.fromRGB(255, 170, 50),
    yellow  = Color3.fromRGB(255, 230, 60),
    white   = Color3.fromRGB(220, 220, 235),
    gray    = Color3.fromRGB(120, 120, 140),
    dimgray = Color3.fromRGB(70, 70, 90),
    btnOff  = Color3.fromRGB(40, 40, 58),
    btnOn   = Color3.fromRGB(50, 35, 90),
    border  = Color3.fromRGB(90, 60, 200),
    pink    = Color3.fromRGB(255, 100, 200),
    cyan    = Color3.fromRGB(60, 220, 255),
}

------------------------------------------------------------------------
-- ADVANCED AC NUKER (v2 - deep multi-layer)
------------------------------------------------------------------------
local AC_NAMES = {
    "anticheat", "anti_cheat", "anti-cheat", "antiexploit", "anti_exploit",
    "anti-exploit", "antihack", "anti_hack", "hackdetect", "cheatguard",
    "gameguard", "securitycheck", "checker", "validator", "flydetect",
    "speeddetect", "noclipdetect", "exploitdetect", "antifly", "antispeed",
    "antinoclip", "antiteleport", "serversecurity", "clientac", "clientsecurity",
    "serverac", "acmodule", "achandler", "acmanager", "protector",
    "guardmodule", "detectmodule", "kickmodule", "banmodule", "flagmodule",
    "monitorscript", "healthmonitor", "speedmonitor", "positionmonitor",
    "movementcheck", "physicscheck", "sanitycheck",
}

local AC_REMOTE_NAMES = {
    "anticheat", "anti_cheat", "security", "validate", "check",
    "detect", "flag", "report", "kick", "ban", "monitor",
    "heartbeat_ac", "ac_heartbeat", "ac_ping", "ac_check",
    "verify", "verification", "integrity", "guard",
}

local nukeCount = 0
local nukeLog = {}

local function matchesAC(name)
    local low = name:lower()
    for _, pattern in pairs(AC_NAMES) do
        if low:find(pattern) then return true end
    end
    return false
end

local function matchesACRemote(name)
    local low = name:lower()
    for _, pattern in pairs(AC_REMOTE_NAMES) do
        if low:find(pattern) then return true end
    end
    return false
end

local function logNuke(action, path)
    nukeCount = nukeCount + 1
    table.insert(nukeLog, "[" .. nukeCount .. "] " .. action .. ": " .. path)
    if #nukeLog > 200 then table.remove(nukeLog, 1) end
end

local function getPath(inst)
    local parts = {}
    local current = inst
    while current and current ~= game do
        table.insert(parts, 1, current.Name)
        current = current.Parent
    end
    return table.concat(parts, ".")
end

local function nukeInstance(inst)
    local path = getPath(inst)
    if inst:IsA("LocalScript") then
        pcall(function() inst.Disabled = true end)
        pcall(function() inst:Destroy() end)
        logNuke("KILLED LocalScript", path)
    elseif inst:IsA("ModuleScript") then
        -- Poison module: replace source so require() returns empty
        pcall(function()
            inst:Destroy()
        end)
        logNuke("DESTROYED ModuleScript", path)
    elseif inst:IsA("RemoteEvent") or inst:IsA("RemoteFunction") then
        pcall(function() inst:Destroy() end)
        logNuke("DESTROYED Remote", path)
    elseif inst:IsA("BindableEvent") or inst:IsA("BindableFunction") then
        pcall(function() inst:Destroy() end)
        logNuke("DESTROYED Bindable", path)
    else
        pcall(function() inst:Destroy() end)
        logNuke("DESTROYED", path)
    end
end

local function deepNukeContainer(container)
    if not container then return end
    pcall(function()
        for _, child in pairs(container:GetDescendants()) do
            if child:IsA("LocalScript") or child:IsA("ModuleScript") then
                if matchesAC(child.Name) then
                    nukeInstance(child)
                end
            elseif child:IsA("RemoteEvent") or child:IsA("RemoteFunction") then
                if matchesACRemote(child.Name) then
                    nukeInstance(child)
                end
            elseif child:IsA("BindableEvent") or child:IsA("BindableFunction") then
                if matchesACRemote(child.Name) then
                    nukeInstance(child)
                end
            end
        end
    end)
end

local function nukeScriptConnections()
    -- Disconnect all RBXScriptConnections on Heartbeat/Stepped that might be AC checks
    -- This is aggressive but effective
    pcall(function()
        if getconnections then
            -- Nuke suspicious Heartbeat connections
            local hbConns = getconnections(RS.Heartbeat)
            for _, conn in pairs(hbConns) do
                pcall(function()
                    local func = conn.Function
                    local info = debug.getinfo and debug.getinfo(func)
                    if info then
                        local src = info.source or ""
                        local low = src:lower()
                        for _, pattern in pairs(AC_NAMES) do
                            if low:find(pattern) then
                                conn:Disable()
                                logNuke("DISABLED Heartbeat connection", src)
                                break
                            end
                        end
                    end
                end)
            end
            
            -- Nuke suspicious Stepped connections
            local stConns = getconnections(RS.Stepped)
            for _, conn in pairs(stConns) do
                pcall(function()
                    local func = conn.Function
                    local info = debug.getinfo and debug.getinfo(func)
                    if info then
                        local src = info.source or ""
                        local low = src:lower()
                        for _, pattern in pairs(AC_NAMES) do
                            if low:find(pattern) then
                                conn:Disable()
                                logNuke("DISABLED Stepped connection", src)
                                break
                            end
                        end
                    end
                end)
            end
            
            -- Nuke RenderStepped AC connections
            local rsConns = getconnections(RS.RenderStepped)
            for _, conn in pairs(rsConns) do
                pcall(function()
                    local func = conn.Function
                    local info = debug.getinfo and debug.getinfo(func)
                    if info then
                        local src = info.source or ""
                        local low = src:lower()
                        for _, pattern in pairs(AC_NAMES) do
                            if low:find(pattern) then
                                conn:Disable()
                                logNuke("DISABLED RenderStepped connection", src)
                                break
                            end
                        end
                    end
                end)
            end
        end
    end)
end

local function nukeMetatableHooks()
    -- Hook __namecall to block AC remote fires
    pcall(function()
        if hookmetamethod and newcclosure then
            local oldNamecall = hookmetamethod(game, "__namecall", newcclosure(function(self, ...)
                local method = getnamecallmethod()
                if method == "FireServer" or method == "InvokeServer" then
                    local name = self.Name:lower()
                    for _, pattern in pairs(AC_REMOTE_NAMES) do
                        if name:find(pattern) then
                            logNuke("BLOCKED " .. method, self:GetFullName())
                            if method == "FireServer" then
                                return nil
                            else
                                return true -- Return truthy for InvokeServer
                            end
                        end
                    end
                end
                return oldNamecall(self, ...)
            end))
            logNuke("HOOKED", "__namecall metatable")
        end
    end)
end

local function nukeKickHook()
    -- Hook Player:Kick to prevent AC kicks
    pcall(function()
        if hookfunction and newcclosure then
            local oldKick = LP.Kick
            hookfunction(LP.Kick, newcclosure(function(self, reason)
                reason = reason or ""
                local low = reason:lower()
                -- Block kicks that mention cheat/exploit/hack
                local blockKeywords = {"cheat", "exploit", "hack", "speed", "fly", "noclip", "teleport", "detect", "violation", "anti", "illegal", "suspect", "ban", "flag"}
                for _, kw in pairs(blockKeywords) do
                    if low:find(kw) then
                        logNuke("BLOCKED KICK", reason)
                        return nil
                    end
                end
                return oldKick(self, reason)
            end))
            logNuke("HOOKED", "Player:Kick")
        end
    end)
end

local function fullNuke()
    nukeCount = 0
    nukeLog = {}
    
    -- Layer 1: Nuke scripts in all accessible containers
    deepNukeContainer(LP:FindFirstChild("PlayerScripts"))
    deepNukeContainer(LP:FindFirstChild("PlayerGui"))
    deepNukeContainer(char)
    deepNukeContainer(game:GetService("ReplicatedFirst"))
    deepNukeContainer(game:GetService("ReplicatedStorage"))
    deepNukeContainer(game:GetService("StarterPlayer"))
    deepNukeContainer(game:GetService("StarterGui"))
    deepNukeContainer(Workspace)
    
    -- Layer 2: Nuke script connections on RunService
    nukeScriptConnections()
    
    -- Layer 3: Hook __namecall to silently block AC remote calls
    nukeMetatableHooks()
    
    -- Layer 4: Hook Kick to prevent AC kicks
    nukeKickHook()
    
    -- Layer 5: Disable error reporting that AC might use
    pcall(function()
        local stats = game:GetService("Stats")
        -- Some ACs use stats service
    end)
    
    -- Layer 6: Clear any AC value stores
    pcall(function()
        for _, v in pairs(game:GetService("ReplicatedStorage"):GetDescendants()) do
            if v:IsA("IntValue") or v:IsA("StringValue") or v:IsA("BoolValue") then
                if matchesACRemote(v.Name) then
                    pcall(function() v:Destroy() end)
                    logNuke("DESTROYED ValueObject", getPath(v))
                end
            end
        end
    end)
    
    return nukeCount
end

------------------------------------------------------------------------
-- XRAY
------------------------------------------------------------------------
local function setXray(on)
    if on then
        for _, part in pairs(Workspace:GetDescendants()) do
            if part:IsA("BasePart") and not part:IsDescendantOf(char or {}) then
                local t = part.Transparency
                if t < 0.7 and part.Name ~= "Baseplate" and part.Name ~= "Terrain" then
                    if not originalTransparency[part] then
                        originalTransparency[part] = t
                    end
                    part.Transparency = 0.75
                end
            end
        end
    else
        for part, t in pairs(originalTransparency) do
            pcall(function() part.Transparency = t end)
        end
        originalTransparency = {}
    end
end

------------------------------------------------------------------------
-- INFINITE JUMP
------------------------------------------------------------------------
conn(UIS.JumpRequest:Connect(function()
    if State.infJump and grab() then
        hmn:ChangeState(Enum.HumanoidStateType.Jumping)
    end
end))

------------------------------------------------------------------------
-- FULLBRIGHT
------------------------------------------------------------------------
local function setFullbright(on)
    if on then
        originalLighting.Ambient = Lighting.Ambient
        originalLighting.Brightness = Lighting.Brightness
        originalLighting.FogEnd = Lighting.FogEnd
        originalLighting.FogStart = Lighting.FogStart
        originalLighting.GlobalShadows = Lighting.GlobalShadows
        originalLighting.OutdoorAmbient = Lighting.OutdoorAmbient
        
        Lighting.Ambient = Color3.new(1, 1, 1)
        Lighting.Brightness = 2
        Lighting.FogEnd = 1000000
        Lighting.FogStart = 1000000
        Lighting.GlobalShadows = false
        Lighting.OutdoorAmbient = Color3.new(1, 1, 1)
        
        for _, eff in pairs(Lighting:GetChildren()) do
            if eff:IsA("Atmosphere") or eff:IsA("BloomEffect") or eff:IsA("ColorCorrectionEffect") then
                if not eff:GetAttribute("_CCv2_hidden") then
                    eff:SetAttribute("_CCv2_hidden", true)
                    eff:SetAttribute("_CCv2_enabled", eff.Enabled)
                    eff.Enabled = false
                end
            end
        end
    else
        pcall(function()
            Lighting.Ambient = originalLighting.Ambient or Lighting.Ambient
            Lighting.Brightness = originalLighting.Brightness or Lighting.Brightness
            Lighting.FogEnd = originalLighting.FogEnd or Lighting.FogEnd
            Lighting.FogStart = originalLighting.FogStart or Lighting.FogStart
            Lighting.GlobalShadows = originalLighting.GlobalShadows
            Lighting.OutdoorAmbient = originalLighting.OutdoorAmbient or Lighting.OutdoorAmbient
        end)
        for _, eff in pairs(Lighting:GetChildren()) do
            if eff:GetAttribute("_CCv2_hidden") then
                eff.Enabled = eff:GetAttribute("_CCv2_enabled")
                eff:SetAttribute("_CCv2_hidden", nil)
                eff:SetAttribute("_CCv2_enabled", nil)
            end
        end
    end
end

------------------------------------------------------------------------
-- ADVANCED NOCLIP (v2 - recursive + new parts)
------------------------------------------------------------------------
local noclipParts = {} -- track originals

local function setNoclipPart(part, on)
    if on then
        if part.CanCollide then
            noclipParts[part] = true
            part.CanCollide = false
        end
    else
        if noclipParts[part] then
            part.CanCollide = true
            noclipParts[part] = nil
        end
    end
end

conn(RS.Stepped:Connect(function()
    if not State.noclip then return end
    if not grab() then return end
    
    -- Character parts
    for _, part in pairs(char:GetDescendants()) do
        if part:IsA("BasePart") then
            part.CanCollide = false
        end
    end
    
    -- Also disable CanCollide on parts near player (small radius noclip bubble)
    -- This prevents getting stuck on edges
    local pos = hrp.Position
    local radius = 8
    for _, part in pairs(Workspace:GetDescendants()) do
        if part:IsA("BasePart") and not part:IsDescendantOf(char) then
            local dist = (part.Position - pos).Magnitude
            if dist < radius then
                if part.CanCollide then
                    setNoclipPart(part, true)
                end
            else
                setNoclipPart(part, false)
            end
        end
    end
end))

-- Restore all noclip parts when disabled
local function restoreNoclip()
    for part, _ in pairs(noclipParts) do
        pcall(function() part.CanCollide = true end)
    end
    noclipParts = {}
end

------------------------------------------------------------------------
-- ADVANCED SPEED (v2 - CFrame speed with anti-detect)
------------------------------------------------------------------------
local speedMode = "walkspeed" -- "walkspeed" or "cframe"
local cframeSpeedActive = false

-- WalkSpeed method (simpler, detectable)
local function applyWalkSpeed(on)
    if on and grab() and hmn then
        hmn.WalkSpeed = speedValue
    elseif grab() and hmn then
        hmn.WalkSpeed = 16 -- default
    end
end

-- CFrame method (harder to detect)
local lastSpeedTick = 0
conn(RS.Heartbeat:Connect(function(dt)
    if not State.speed then return end
    if not grab() then return end
    
    if speedMode == "walkspeed" then
        hmn.WalkSpeed = speedValue
    elseif speedMode == "cframe" then
        -- CFrame-based movement: keep WalkSpeed normal but move via CFrame
        hmn.WalkSpeed = 16
        
        local moveDir = hmn.MoveDirection
        if moveDir.Magnitude > 0 then
            local boost = (speedValue - 16) * dt
            local offset = moveDir.Unit * boost
            hrp.CFrame = hrp.CFrame + offset
        end
    end
end))

------------------------------------------------------------------------
-- ADVANCED FLY (v2 - smooth acceleration, sprint, freelook, anti-fling)
------------------------------------------------------------------------
local flyActive = false
local flyBV, flyBG
local flyVelocity = Vector3.new(0, 0, 0)
local flyAcceleration = 8    -- how fast to reach target speed
local flyDeceleration = 12   -- how fast to stop
local flySprinting = false

local function startFly()
    if not grab() then return end
    flyActive = true
    flyVelocity = Vector3.new(0, 0, 0)
    
    -- Anti-fling: anchor character temporarily
    pcall(function() hrp.Anchored = false end)
    
    flyBV = Instance.new("BodyVelocity")
    flyBV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    flyBV.Velocity = Vector3.new(0, 0, 0)
    flyBV.P = 10000
    flyBV.Parent = hrp
    
    flyBG = Instance.new("BodyGyro")
    flyBG.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
    flyBG.D = 300
    flyBG.P = 15000
    flyBG.Parent = hrp
    
    -- Prevent fall damage / death on land
    pcall(function()
        hmn:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
        hmn:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
    end)
end

local function stopFly()
    flyActive = false
    flyVelocity = Vector3.new(0, 0, 0)
    
    pcall(function() if flyBV then flyBV:Destroy() end end)
    pcall(function() if flyBG then flyBG:Destroy() end end)
    flyBV = nil
    flyBG = nil
    
    -- Restore fall states
    pcall(function()
        if hmn then
            hmn:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
            hmn:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
        end
    end)
end

-- Fly movement loop
conn(RS.Heartbeat:Connect(function(dt)
    if not flyActive or not State.fly then return end
    if not grab() or not flyBV or not flyBG then return end
    
    local cf = Camera.CFrame
    local targetDir = Vector3.new(0, 0, 0)
    
    -- Sprint detection
    flySprinting = UIS:IsKeyDown(Enum.KeyCode.LeftControl) or UIS:IsKeyDown(Enum.KeyCode.RightControl)
    local currentFlySpeed = flySprinting and flySprint or flySpeed
    
    -- WASD + Space/Shift for direction
    if UIS:IsKeyDown(Enum.KeyCode.W) then targetDir = targetDir + cf.LookVector end
    if UIS:IsKeyDown(Enum.KeyCode.S) then targetDir = targetDir - cf.LookVector end
    if UIS:IsKeyDown(Enum.KeyCode.A) then targetDir = targetDir - cf.RightVector end
    if UIS:IsKeyDown(Enum.KeyCode.D) then targetDir = targetDir + cf.RightVector end
    if UIS:IsKeyDown(Enum.KeyCode.Space) then targetDir = targetDir + Vector3.new(0, 1, 0) end
    if UIS:IsKeyDown(Enum.KeyCode.LeftShift) then targetDir = targetDir - Vector3.new(0, 1, 0) end
    
    -- Mobile fly: use MoveDirection from thumbstick
    if UIS.TouchEnabled then
        local moveDir = hmn.MoveDirection
        if moveDir.Magnitude > 0.1 then
            targetDir = targetDir + moveDir
        end
    end
    
    local targetVelocity
    if targetDir.Magnitude > 0 then
        targetVelocity = targetDir.Unit * currentFlySpeed
    else
        targetVelocity = Vector3.new(0, 0, 0)
    end
    
    -- Smooth acceleration/deceleration
    local accel = targetDir.Magnitude > 0 and flyAcceleration or flyDeceleration
    flyVelocity = flyVelocity:Lerp(targetVelocity, math.min(1, accel * dt))
    
    -- Apply
    flyBV.Velocity = flyVelocity
    flyBG.CFrame = cf
    
    -- Anti-fling: keep velocity reasonable
    if hrp.AssemblyLinearVelocity.Magnitude > currentFlySpeed * 1.5 then
        hrp.AssemblyLinearVelocity = flyVelocity
    end
end))

------------------------------------------------------------------------
-- ANTI-AFK
------------------------------------------------------------------------
do
    local vu = game:GetService("VirtualUser")
    conn(LP.Idled:Connect(function()
        if State.antiAfk then
            vu:CaptureController()
            vu:ClickButton2(Vector2.new())
        end
    end))
end

------------------------------------------------------------------------
-- GUI
------------------------------------------------------------------------
local gui = Instance.new("ScreenGui")
gui.Name = "CCUtilGui_v2"
gui.ResetOnSpawn = false
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
gui.Parent = LP.PlayerGui

-- Main frame
local main = Instance.new("Frame")
main.Size = UDim2.new(0, 270, 0, 420)
main.Position = UDim2.new(0, 15, 0.5, -210)
main.BackgroundColor3 = C.bg
main.BorderSizePixel = 0
main.Active = true
main.Draggable = true
main.Visible = menuOpen
main.Parent = gui
Instance.new("UICorner", main).CornerRadius = UDim.new(0, 10)
local mainStroke = Instance.new("UIStroke", main)
mainStroke.Color = C.border
mainStroke.Thickness = 2

-- Header
local header = Instance.new("Frame")
header.Size = UDim2.new(1, 0, 0, 40)
header.BackgroundColor3 = C.header
header.BorderSizePixel = 0
header.Parent = main
Instance.new("UICorner", header).CornerRadius = UDim.new(0, 10)

local headerFix = Instance.new("Frame")
headerFix.Size = UDim2.new(1, 0, 0, 12)
headerFix.Position = UDim2.new(0, 0, 1, -12)
headerFix.BackgroundColor3 = C.header
headerFix.BorderSizePixel = 0
headerFix.Parent = header

local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, -10, 1, 0)
title.Position = UDim2.new(0, 10, 0, 0)
title.BackgroundTransparency = 1
title.Text = "⚡ CC UTIL v2"
title.TextColor3 = C.accent
title.Font = Enum.Font.GothamBold
title.TextSize = 16
title.TextXAlignment = Enum.TextXAlignment.Left
title.Parent = header

local closeBtn = Instance.new("TextButton")
closeBtn.Size = UDim2.new(0, 30, 0, 30)
closeBtn.Position = UDim2.new(1, -35, 0, 5)
closeBtn.BackgroundColor3 = C.red
closeBtn.BackgroundTransparency = 0.5
closeBtn.BorderSizePixel = 0
closeBtn.Text = "X"
closeBtn.TextColor3 = C.white
closeBtn.Font = Enum.Font.GothamBold
closeBtn.TextSize = 14
closeBtn.Parent = header
Instance.new("UICorner", closeBtn).CornerRadius = UDim.new(0, 6)
closeBtn.MouseButton1Click:Connect(function()
    menuOpen = false
    main.Visible = false
end)

-- Scroll frame
local scroll = Instance.new("ScrollingFrame")
scroll.Size = UDim2.new(1, -16, 1, -48)
scroll.Position = UDim2.new(0, 8, 0, 44)
scroll.BackgroundTransparency = 1
scroll.BorderSizePixel = 0
scroll.ScrollBarThickness = 4
scroll.ScrollBarImageColor3 = C.accent
scroll.CanvasSize = UDim2.new(0, 0, 0, 0)
scroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
scroll.Parent = main

local layout = Instance.new("UIListLayout", scroll)
layout.Padding = UDim.new(0, 4)
layout.SortOrder = Enum.SortOrder.LayoutOrder

------------------------------------------------------------------------
-- TOGGLE BUTTON FACTORY
------------------------------------------------------------------------
local toggleButtons = {}

local function createToggle(name, stateKey, description, color, order, callback)
    local row = Instance.new("Frame")
    row.Size = UDim2.new(1, -4, 0, 38)
    row.BackgroundColor3 = C.panel
    row.BorderSizePixel = 0
    row.LayoutOrder = order
    row.Parent = scroll
    Instance.new("UICorner", row).CornerRadius = UDim.new(0, 8)
    
    local bar = Instance.new("Frame")
    bar.Size = UDim2.new(0, 4, 0.7, 0)
    bar.Position = UDim2.new(0, 4, 0.15, 0)
    bar.BackgroundColor3 = State[stateKey] and color or C.dimgray
    bar.BorderSizePixel = 0
    bar.Parent = row
    Instance.new("UICorner", bar).CornerRadius = UDim.new(0, 2)
    
    local lbl = Instance.new("TextLabel")
    lbl.Size = UDim2.new(0.55, 0, 0, 16)
    lbl.Position = UDim2.new(0, 16, 0, 3)
    lbl.BackgroundTransparency = 1
    lbl.Text = name
    lbl.TextColor3 = C.white
    lbl.Font = Enum.Font.GothamBold
    lbl.TextSize = 13
    lbl.TextXAlignment = Enum.TextXAlignment.Left
    lbl.Parent = row
    
    local desc = Instance.new("TextLabel")
    desc.Size = UDim2.new(0.7, 0, 0, 12)
    desc.Position = UDim2.new(0, 16, 0, 20)
    desc.BackgroundTransparency = 1
    desc.Text = description
    desc.TextColor3 = C.gray
    desc.Font = Enum.Font.Gotham
    desc.TextSize = 10
    desc.TextXAlignment = Enum.TextXAlignment.Left
    desc.Parent = row
    
    local btn = Instance.new("TextButton")
    btn.Size = UDim2.new(0, 52, 0, 24)
    btn.Position = UDim2.new(1, -60, 0.5, -12)
    btn.BorderSizePixel = 0
    btn.Text = State[stateKey] and "ON" or "OFF"
    btn.TextColor3 = State[stateKey] and C.green or C.red
    btn.BackgroundColor3 = State[stateKey] and C.btnOn or C.btnOff
    btn.Font = Enum.Font.GothamBold
    btn.TextSize = 12
    btn.AutoButtonColor = false
    btn.Parent = row
    Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 6)
    Instance.new("UIStroke", btn).Color = State[stateKey] and C.green or C.dimgray
    
    btn.MouseButton1Click:Connect(function()
        State[stateKey] = not State[stateKey]
        local on = State[stateKey]
        btn.Text = on and "ON" or "OFF"
        btn.TextColor3 = on and C.green or C.red
        btn.BackgroundColor3 = on and C.btnOn or C.btnOff
        btn:FindFirstChildOfClass("UIStroke").Color = on and C.green or C.dimgray
        bar.BackgroundColor3 = on and color or C.dimgray
        if callback then callback(on) end
    end)
    
    toggleButtons[stateKey] = {btn = btn, bar = bar, color = color, lbl = lbl}
end

------------------------------------------------------------------------
-- CREATE TOGGLES
------------------------------------------------------------------------
createToggle("XRAY", "xray", "See through walls", C.accent, 1, function(on)
    setXray(on)
end)

createToggle("INF JUMP", "infJump", "Jump in mid-air", C.cyan, 2, nil)

createToggle("FULLBRIGHT", "fullbright", "Remove darkness & fog", C.orange, 3, function(on)
    setFullbright(on)
end)

createToggle("SPEED [WS]", "speed", "Boosted movement speed", C.green, 4, function(on)
    if not on then
        applyWalkSpeed(false)
    end
end)

createToggle("NOCLIP", "noclip", "Phase through everything", C.pink, 5, function(on)
    if not on then restoreNoclip() end
end)

createToggle("FLY", "fly", "Smooth fly + sprint (Ctrl)", C.accent2, 6, function(on)
    if on then startFly() else stopFly() end
end)

createToggle("ANTI-AFK", "antiAfk", "Prevent idle kick", C.gray, 7, nil)

createToggle("AC NUKER", "acNuker", "Deep multi-layer AC destroy", C.red, 8, function(on)
    if on then
        local n = fullNuke()
        print("[CC UTIL v2] AC Nuker: " .. n .. " objects nuked")
        for _, log in pairs(nukeLog) do
            print("  " .. log)
        end
        -- Re-nuke periodically
        task.spawn(function()
            while State.acNuker and task.wait(4) do
                deepNukeContainer(LP:FindFirstChild("PlayerScripts"))
                deepNukeContainer(LP:FindFirstChild("PlayerGui"))
                deepNukeContainer(char)
                deepNukeContainer(game:GetService("ReplicatedStorage"))
                nukeScriptConnections()
            end
        end)
    end
end)

------------------------------------------------------------------------
-- SPEED CONTROLS
------------------------------------------------------------------------
local speedRow = Instance.new("Frame")
speedRow.Size = UDim2.new(1, -4, 0, 32)
speedRow.BackgroundColor3 = C.panel
speedRow.BorderSizePixel = 0
speedRow.LayoutOrder = 9
speedRow.Parent = scroll
Instance.new("UICorner", speedRow).CornerRadius = UDim.new(0, 8)

local speedLbl = Instance.new("TextLabel")
speedLbl.Size = UDim2.new(0.4, 0, 1, 0)
speedLbl.Position = UDim2.new(0, 12, 0, 0)
speedLbl.BackgroundTransparency = 1
speedLbl.Text = "Spd: " .. speedValue
speedLbl.TextColor3 = C.white
speedLbl.Font = Enum.Font.GothamBold
speedLbl.TextSize = 12
speedLbl.TextXAlignment = Enum.TextXAlignment.Left
speedLbl.Parent = speedRow

-- Speed mode toggle button
local modeBtn = Instance.new("TextButton")
modeBtn.Size = UDim2.new(0, 40, 0, 20)
modeBtn.Position = UDim2.new(0.42, 0, 0.5, -10)
modeBtn.BackgroundColor3 = C.btnOff
modeBtn.BorderSizePixel = 0
modeBtn.Text = "WS"
modeBtn.TextColor3 = C.green
modeBtn.Font = Enum.Font.GothamBold
modeBtn.TextSize = 10
modeBtn.Parent = speedRow
Instance.new("UICorner", modeBtn).CornerRadius = UDim.new(0, 4)

modeBtn.MouseButton1Click:Connect(function()
    if speedMode == "walkspeed" then
        speedMode = "cframe"
        modeBtn.Text = "CF"
        modeBtn.TextColor3 = C.cyan
        -- Update toggle label
        toggleButtons["speed"].lbl.Text = "SPEED [CF]"
    else
        speedMode = "walkspeed"
        modeBtn.Text = "WS"
        modeBtn.TextColor3 = C.green
        toggleButtons["speed"].lbl.Text = "SPEED [WS]"
    end
end)

local function makeSpeedBtn(text, xOff, delta)
    local b = Instance.new("TextButton")
    b.Size = UDim2.new(0, 30, 0, 22)
    b.Position = UDim2.new(1, xOff, 0.5, -11)
    b.BackgroundColor3 = C.btnOff
    b.BorderSizePixel = 0
    b.Text = text
    b.TextColor3 = C.white
    b.Font = Enum.Font.GothamBold
    b.TextSize = 14
    b.Parent = speedRow
    Instance.new("UICorner", b).CornerRadius = UDim.new(0, 4)
    b.MouseButton1Click:Connect(function()
        speedValue = math.clamp(speedValue + delta, 16, 500)
        speedLbl.Text = "Spd: " .. speedValue
    end)
end
makeSpeedBtn("-", -70, -10)
makeSpeedBtn("+", -35, 10)

------------------------------------------------------------------------
-- FLY SPEED CONTROLS
------------------------------------------------------------------------
local flyRow = Instance.new("Frame")
flyRow.Size = UDim2.new(1, -4, 0, 32)
flyRow.BackgroundColor3 = C.panel
flyRow.BorderSizePixel = 0
flyRow.LayoutOrder = 10
flyRow.Parent = scroll
Instance.new("UICorner", flyRow).CornerRadius = UDim.new(0, 8)

local flyLbl = Instance.new("TextLabel")
flyLbl.Size = UDim2.new(0.5, 0, 1, 0)
flyLbl.Position = UDim2.new(0, 12, 0, 0)
flyLbl.BackgroundTransparency = 1
flyLbl.Text = "Fly: " .. flySpeed .. " | Sprint: " .. flySprint
flyLbl.TextColor3 = C.white
flyLbl.Font = Enum.Font.GothamBold
flyLbl.TextSize = 11
flyLbl.TextXAlignment = Enum.TextXAlignment.Left
flyLbl.Parent = flyRow

local function makeFlyBtn(text, xOff, delta)
    local b = Instance.new("TextButton")
    b.Size = UDim2.new(0, 30, 0, 22)
    b.Position = UDim2.new(1, xOff, 0.5, -11)
    b.BackgroundColor3 = C.btnOff
    b.BorderSizePixel = 0
    b.Text = text
    b.TextColor3 = C.white
    b.Font = Enum.Font.GothamBold
    b.TextSize = 14
    b.Parent = flyRow
    Instance.new("UICorner", b).CornerRadius = UDim.new(0, 4)
    b.MouseButton1Click:Connect(function()
        flySpeed = math.clamp(flySpeed + delta, 10, 500)
        flySprint = math.clamp(flySpeed * 2.5, 25, 1000)
        flyLbl.Text = "Fly: " .. flySpeed .. " | Sprint: " .. math.floor(flySprint)
    end)
end
makeFlyBtn("-", -70, -20)
makeFlyBtn("+", -35, 20)

------------------------------------------------------------------------
-- AC NUKER LOG VIEWER
------------------------------------------------------------------------
local logRow = Instance.new("Frame")
logRow.Size = UDim2.new(1, -4, 0, 26)
logRow.BackgroundColor3 = C.panel
logRow.BorderSizePixel = 0
logRow.LayoutOrder = 11
logRow.Parent = scroll
Instance.new("UICorner", logRow).CornerRadius = UDim.new(0, 8)

local logLbl = Instance.new("TextLabel")
logLbl.Size = UDim2.new(0.6, 0, 1, 0)
logLbl.Position = UDim2.new(0, 12, 0, 0)
logLbl.BackgroundTransparency = 1
logLbl.Text = "AC Log: 0 nuked"
logLbl.TextColor3 = C.gray
logLbl.Font = Enum.Font.Gotham
logLbl.TextSize = 11
logLbl.TextXAlignment = Enum.TextXAlignment.Left
logLbl.Parent = logRow

local logBtn = Instance.new("TextButton")
logBtn.Size = UDim2.new(0, 50, 0, 18)
logBtn.Position = UDim2.new(1, -58, 0.5, -9)
logBtn.BackgroundColor3 = C.btnOff
logBtn.BorderSizePixel = 0
logBtn.Text = "PRINT"
logBtn.TextColor3 = C.orange
logBtn.Font = Enum.Font.GothamBold
logBtn.TextSize = 10
logBtn.Parent = logRow
Instance.new("UICorner", logBtn).CornerRadius = UDim.new(0, 4)

logBtn.MouseButton1Click:Connect(function()
    print("=== AC NUKER LOG ===")
    print("Total nuked: " .. nukeCount)
    for _, log in pairs(nukeLog) do
        print("  " .. log)
    end
    print("====================")
end)

-- Update log label periodically
task.spawn(function()
    while task.wait(2) do
        pcall(function()
            logLbl.Text = "AC Log: " .. nukeCount .. " nuked"
        end)
    end
end)

------------------------------------------------------------------------
-- CREDITS
------------------------------------------------------------------------
local credRow = Instance.new("Frame")
credRow.Size = UDim2.new(1, -4, 0, 22)
credRow.BackgroundTransparency = 1
credRow.LayoutOrder = 99
credRow.Parent = scroll

local credLbl = Instance.new("TextLabel")
credLbl.Size = UDim2.new(1, 0, 1, 0)
credLbl.BackgroundTransparency = 1
credLbl.Text = "⚡ CC Util v2 | RightAlt to toggle"
credLbl.TextColor3 = C.dimgray
credLbl.Font = Enum.Font.Gotham
credLbl.TextSize = 10
credLbl.Parent = credRow

------------------------------------------------------------------------
-- TOGGLE MENU KEY
------------------------------------------------------------------------
conn(UIS.InputBegan:Connect(function(inp, gpe)
    if gpe then return end
    if inp.KeyCode == Enum.KeyCode.RightAlt then
        menuOpen = not menuOpen
        main.Visible = menuOpen
    end
end))

------------------------------------------------------------------------
-- MOBILE TOGGLE
------------------------------------------------------------------------
local isMobile = UIS.TouchEnabled and not UIS.KeyboardEnabled

if isMobile then
    local mobileToggle = Instance.new("TextButton")
    mobileToggle.Size = UDim2.new(0, 50, 0, 50)
    mobileToggle.Position = UDim2.new(0, 10, 0.3, 0)
    mobileToggle.BackgroundColor3 = C.accent
    mobileToggle.BackgroundTransparency = 0.3
    mobileToggle.BorderSizePixel = 0
    mobileToggle.Text = "⚡"
    mobileToggle.TextSize = 24
    mobileToggle.Font = Enum.Font.GothamBold
    mobileToggle.TextColor3 = C.white
    mobileToggle.Parent = gui
    mobileToggle.Draggable = true
    mobileToggle.Active = true
    Instance.new("UICorner", mobileToggle).CornerRadius = UDim.new(0, 25)
    Instance.new("UIStroke", mobileToggle).Color = C.border
    
    mobileToggle.MouseButton1Click:Connect(function()
        menuOpen = not menuOpen
        main.Visible = menuOpen
    end)
    
    -- Mobile fly controls: dedicated up/down buttons when flying
    local flyUpBtn = Instance.new("TextButton")
    flyUpBtn.Size = UDim2.new(0, 60, 0, 40)
    flyUpBtn.Position = UDim2.new(1, -75, 0.5, -50)
    flyUpBtn.BackgroundColor3 = C.accent2
    flyUpBtn.BackgroundTransparency = 0.4
    flyUpBtn.BorderSizePixel = 0
    flyUpBtn.Text = "▲ UP"
    flyUpBtn.TextColor3 = C.white
    flyUpBtn.Font = Enum.Font.GothamBold
    flyUpBtn.TextSize = 12
    flyUpBtn.Visible = false
    flyUpBtn.Parent = gui
    Instance.new("UICorner", flyUpBtn).CornerRadius = UDim.new(0, 8)
    
    local flyDownBtn = Instance.new("TextButton")
    flyDownBtn.Size = UDim2.new(0, 60, 0, 40)
    flyDownBtn.Position = UDim2.new(1, -75, 0.5, 10)
    flyDownBtn.BackgroundColor3 = C.accent2
    flyDownBtn.BackgroundTransparency = 0.4
    flyDownBtn.BorderSizePixel = 0
    flyDownBtn.Text = "▼ DN"
    flyDownBtn.TextColor3 = C.white
    flyDownBtn.Font = Enum.Font.GothamBold
    flyDownBtn.TextSize = 12
    flyDownBtn.Visible = false
    flyDownBtn.Parent = gui
    Instance.new("UICorner", flyDownBtn).CornerRadius = UDim.new(0, 8)
    
    local mFlyUp = false
    local mFlyDown = false
    
    flyUpBtn.MouseButton1Down:Connect(function() mFlyUp = true end)
    flyUpBtn.MouseButton1Up:Connect(function() mFlyUp = false end)
    flyDownBtn.MouseButton1Down:Connect(function() mFlyDown = true end)
    flyDownBtn.MouseButton1Up:Connect(function() mFlyDown = false end)
    
    -- Show/hide fly buttons based on fly state
    task.spawn(function()
        while task.wait(0.3) do
            flyUpBtn.Visible = State.fly
            flyDownBtn.Visible = State.fly
        end
    end)
    
    -- Apply mobile fly up/down
    conn(RS.Heartbeat:Connect(function()
        if not State.fly or not flyActive or not flyBV then return end
        local extra = Vector3.new(0, 0, 0)
        if mFlyUp then extra = extra + Vector3.new(0, flySpeed, 0) end
        if mFlyDown then extra = extra - Vector3.new(0, flySpeed, 0) end
        if extra.Magnitude > 0 then
            flyBV.Velocity = flyBV.Velocity + extra
        end
    end))
end

------------------------------------------------------------------------
-- XRAY AUTO-REFRESH
------------------------------------------------------------------------
task.spawn(function()
    while task.wait(5) do
        if State.xray then setXray(true) end
    end
end)

------------------------------------------------------------------------
-- PRINT
------------------------------------------------------------------------
print("=== CUBE COMBINATION UTILITY v2 ===")
print("  Press RIGHT ALT to toggle menu (mobile: tap ⚡)")
print("  Features: Xray, Inf Jump, Fullbright, Speed (WS/CF), Noclip, Fly, Anti-AFK, AC Nuker")
print("  Speed modes: WS = WalkSpeed | CF = CFrame (stealth)")
print("  Fly: WASD + Space/Shift | Hold Ctrl to sprint")
print("  AC Nuker: 6-layer deep nuke with kick protection")
print("====================================")
INFO