CYBIX MOD EXECUTER
Key RequiredUniversal

CYBIX MOD EXECUTER

Universal ScriptCYBIXCYBIX 171 views 1.1K executesUpdated Aug 1, 2026
Unrated
00
Lua Script•2540 lines (90912 chars)
local p = game:GetService("Players").LocalPlayer
local rs = game:GetService("RunService")

local g = Instance.new("ScreenGui")
g.Name = "CybixExecFinal"
g.ResetOnSpawn = false
g.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
g.Parent = p:WaitForChild("PlayerGui")

-- MAIN FRAME
local f = Instance.new("Frame", g)
f.Size = UDim2.new(0, 560, 0, 420)
f.Position = UDim2.new(0.5, -280, 0.5, -210)
f.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
f.BorderSizePixel = 0
f.Active = true
Instance.new("UICorner", f).CornerRadius = UDim.new(0, 12)

-- RGB BACKGROUND
task.spawn(function()
    while f.Parent do
        for i = 0, 1, 0.01 do
            if not f.Parent then break end
            f.BackgroundColor3 = Color3.fromHSV(i, 0.7, 0.9)
            task.wait(0.03)
        end
    end
end)

-- HEADER
local h = Instance.new("Frame", f)
h.Size = UDim2.new(1, 0, 0, 40)
h.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
h.BorderSizePixel = 0
Instance.new("UICorner", h).CornerRadius = UDim.new(0, 12)

local title = Instance.new("TextLabel", h)
title.Size = UDim2.new(1, -60, 1, 0)
title.Position = UDim2.new(0, 10, 0, 0)
title.BackgroundTransparency = 1
title.Text = "CYBIX SCRIPT DESIGNER (XENO)"
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamBold
title.TextScaled = true

-- X BUTTON
local x = Instance.new("TextButton", h)
x.Size = UDim2.new(0, 40, 0, 28)
x.Position = UDim2.new(1, -50, 0.5, -14)
x.BackgroundColor3 = Color3.fromRGB(160, 40, 40)
x.Text = "X"
x.TextColor3 = Color3.fromRGB(255, 255, 255)
x.Font = Enum.Font.GothamBold
x.TextScaled = true
x.BorderSizePixel = 0
Instance.new("UICorner", x).CornerRadius = UDim.new(0, 8)
x.MouseButton1Click:Connect(function()
    g:Destroy()
end)

-- DRAGGING
do
    local dragging, dragInput, dragStart, startPos
    h.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            dragging = true
            dragStart = input.Position
            startPos = f.Position
            input.Changed:Connect(function()
                if input.UserInputState == Enum.UserInputState.End then
                    dragging = false
                end
            end)
        end
    end)

    h.InputChanged:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement then
            dragInput = input
        end
    end)

    rs.RenderStepped:Connect(function()
        if dragging and dragInput then
            local delta = dragInput.Position - dragStart
            f.Position = UDim2.new(
                startPos.X.Scale,
                startPos.X.Offset + delta.X,
                startPos.Y.Scale,
                startPos.Y.Offset + delta.Y
            )
        end
    end)
end

-- SIDEBAR
local sidebar = Instance.new("Frame", f)
sidebar.Size = UDim2.new(0, 120, 1, -40)
sidebar.Position = UDim2.new(0, 0, 0, 40)
sidebar.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
sidebar.BorderSizePixel = 0
Instance.new("UICorner", sidebar).CornerRadius = UDim.new(0, 10)

local sLayout = Instance.new("UIListLayout", sidebar)
sLayout.Padding = UDim.new(0, 8)
sLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
sLayout.SortOrder = Enum.SortOrder.LayoutOrder

local function makeTab(name, order)
    local b = Instance.new("TextButton", sidebar)
    b.Size = UDim2.new(1, -12, 0, 36)
    b.LayoutOrder = order
    b.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
    b.TextColor3 = Color3.fromRGB(255, 255, 255)
    b.Font = Enum.Font.GothamBold
    b.TextScaled = true
    b.Text = name
    b.BorderSizePixel = 0
    Instance.new("UICorner", b).CornerRadius = UDim.new(0, 8)
    return b
end

local tabDesign  = makeTab("SCRIPT DESIGN", 1)
local tabHelp    = makeTab("HELP", 2)
local tabConsole = makeTab("CONSOLE", 3)
local tabHI      = makeTab("HI", 4)

-- CONTENT AREA
local content = Instance.new("Frame", f)
content.Size = UDim2.new(1, -140, 1, -40)
content.Position = UDim2.new(0, 140, 0, 40)
content.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
content.BorderSizePixel = 0
Instance.new("UICorner", content).CornerRadius = UDim.new(0, 10)

local pages = {}
local currentPage

local function makePage()
    local p = Instance.new("Frame", content)
    p.Size = UDim2.new(1, -10, 1, -10)
    p.Position = UDim2.new(0, 5, 0, 5)
    p.BackgroundTransparency = 1
    p.Visible = false
    return p
end

local function switchPage(name)
    if currentPage then
        currentPage.Visible = false
    end
    currentPage = pages[name]
    if currentPage then
        currentPage.Visible = true
    end
end

-- SCRIPT DESIGN PAGE
local pageDesign = makePage()
pages["SCRIPT DESIGN"] = pageDesign

local editorFrame = Instance.new("Frame", pageDesign)
editorFrame.Size = UDim2.new(1, -10, 1, -80)
editorFrame.Position = UDim2.new(0, 5, 0, 5)
editorFrame.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
editorFrame.BorderSizePixel = 0
Instance.new("UICorner", editorFrame).CornerRadius = UDim.new(0, 10)

local editorScroll = Instance.new("ScrollingFrame", editorFrame)
editorScroll.Size = UDim2.new(1, -8, 1, -8)
editorScroll.Position = UDim2.new(0, 4, 0, 4)
editorScroll.BackgroundTransparency = 1
editorScroll.ScrollBarThickness = 6
editorScroll.CanvasSize = UDim2.new(0, 0, 0, 2000)

local editorBox = Instance.new("TextBox", editorScroll)
editorBox.Size = UDim2.new(1, -10, 0, 2000)
editorBox.Position = UDim2.new(0, 5, 0, 5)
editorBox.BackgroundTransparency = 1
editorBox.TextColor3 = Color3.fromRGB(255, 255, 255)
editorBox.Font = Enum.Font.Code
editorBox.TextSize = 18
editorBox.MultiLine = true
editorBox.ClearTextOnFocus = false
editorBox.TextWrapped = true
editorBox.TextXAlignment = Enum.TextXAlignment.Left
editorBox.TextYAlignment = Enum.TextYAlignment.Top
editorBox.Text = "-- Paste your script here and press EXECUTE"

-- HELP PAGE
local pageHelp = makePage()
pages["HELP"] = pageHelp

local helpTitle = Instance.new("TextLabel", pageHelp)
helpTitle.Size = UDim2.new(1, -20, 0, 40)
helpTitle.Position = UDim2.new(0, 10, 0, 10)
helpTitle.BackgroundTransparency = 1
helpTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
helpTitle.Font = Enum.Font.GothamBold
helpTitle.TextScaled = true
helpTitle.Text = "CYBIX LOCAL SCRIPT AI"

local promptBox = Instance.new("TextBox", pageHelp)
promptBox.Size = UDim2.new(1, -20, 0, 120)
promptBox.Position = UDim2.new(0, 10, 0, 60)
promptBox.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
promptBox.TextColor3 = Color3.fromRGB(255, 255, 255)
promptBox.Font = Enum.Font.Code
promptBox.TextSize = 18
promptBox.MultiLine = true
promptBox.ClearTextOnFocus = false
promptBox.TextWrapped = true
promptBox.TextXAlignment = Enum.TextXAlignment.Left
promptBox.TextYAlignment = Enum.TextYAlignment.Top
promptBox.Text = "Example prompts:\n- gen me walkspeed script\n- gen me jump power script\n- gen me camera script\n- gen me gui button script"
Instance.new("UICorner", promptBox).CornerRadius = UDim.new(0, 10)

local genButton = Instance.new("TextButton", pageHelp)
genButton.Size = UDim2.new(0, 220, 0, 40)
genButton.Position = UDim2.new(0, 10, 0, 200)
genButton.BackgroundColor3 = Color3.fromRGB(60, 120, 200)
genButton.Text = "GENERATE LOCAL SCRIPT"
genButton.TextColor3 = Color3.fromRGB(255, 255, 255)
genButton.Font = Enum.Font.GothamBold
genButton.TextScaled = true
genButton.BorderSizePixel = 0
Instance.new("UICorner", genButton).CornerRadius = UDim.new(0, 10)

local helpInfo = Instance.new("TextLabel", pageHelp)
helpInfo.Size = UDim2.new(1, -20, 0, 120)
helpInfo.Position = UDim2.new(0, 10, 0, 250)
helpInfo.BackgroundTransparency = 1
helpInfo.TextColor3 = Color3.fromRGB(230, 230, 230)
helpInfo.Font = Enum.Font.Gotham
helpInfo.TextSize = 14
helpInfo.TextWrapped = true
helpInfo.TextXAlignment = Enum.TextXAlignment.Left
helpInfo.Text = "CYBIX AI generates simple LOCAL scripts.\nUse clear prompts like:\n• gen me walkspeed script\n• gen me jump power script\n• gen me camera script\n• gen me gui button script"

-- CONSOLE PAGE
local pageConsole = makePage()
pages["CONSOLE"] = pageConsole

local consoleFrame = Instance.new("ScrollingFrame", pageConsole)
consoleFrame.Size = UDim2.new(1, -10, 1, -50)
consoleFrame.Position = UDim2.new(0, 5, 0, 5)
consoleFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
consoleFrame.ScrollBarThickness = 6
consoleFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
Instance.new("UICorner", consoleFrame).CornerRadius = UDim.new(0, 8)

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

local clearWarningsButton = Instance.new("TextButton", pageConsole)
clearWarningsButton.Size = UDim2.new(0, 160, 0, 32)
clearWarningsButton.Position = UDim2.new(1, -170, 1, -40)
clearWarningsButton.BackgroundColor3 = Color3.fromRGB(220, 180, 60)
clearWarningsButton.Text = "CLEAR WARNINGS"
clearWarningsButton.TextColor3 = Color3.fromRGB(0, 0, 0)
clearWarningsButton.Font = Enum.Font.GothamBold
clearWarningsButton.TextScaled = true
clearWarningsButton.BorderSizePixel = 0
Instance.new("UICorner", clearWarningsButton).CornerRadius = UDim.new(0, 8)

local function addLog(kind, msg, fix)
    local row = Instance.new("Frame", consoleFrame)
    row.Size = UDim2.new(1, -4, 0, 40)
    row.BackgroundTransparency = 1

    local icon = Instance.new("TextLabel", row)
    icon.Size = UDim2.new(0, 32, 1, 0)
    icon.BackgroundTransparency = 1
    icon.Font = Enum.Font.GothamBold
    icon.TextScaled = true

    local text = Instance.new("TextLabel", row)
    text.Size = UDim2.new(1, -40, 1, 0)
    text.Position = UDim2.new(0, 40, 0, 0)
    text.BackgroundTransparency = 1
    text.Font = Enum.Font.Gotham
    text.TextSize = 14
    text.TextWrapped = true
    text.TextXAlignment = Enum.TextXAlignment.Left
    text.TextYAlignment = Enum.TextYAlignment.Top

    if kind == "error" then
        icon.Text = "⛔"
        icon.TextColor3 = Color3.fromRGB(255, 60, 60)
        text.TextColor3 = Color3.fromRGB(255, 180, 180)
    elseif kind == "warn" then
        icon.Text = "⚠️"
        icon.TextColor3 = Color3.fromRGB(255, 220, 60)
        text.TextColor3 = Color3.fromRGB(255, 240, 180)
    else
        icon.Text = "👍"
        icon.TextColor3 = Color3.fromRGB(80, 220, 120)
        text.TextColor3 = Color3.fromRGB(200, 255, 200)
    end

    local ts = os.date("%H:%M:%S")
    if fix and fix ~= "" then
        text.Text = "[" .. ts .. "] " .. msg .. "\nFix: " .. fix
    else
        text.Text = "[" .. ts .. "] " .. msg
    end

    consoleFrame.CanvasSize = UDim2.new(0, 0, 0, consoleLayout.AbsoluteContentSize.Y + 10)
    consoleFrame.CanvasPosition = Vector2.new(0, math.max(0, consoleLayout.AbsoluteContentSize.Y - consoleFrame.AbsoluteSize.Y))
end

clearWarningsButton.MouseButton1Click:Connect(function()
    for _, child in ipairs(consoleFrame:GetChildren()) do
        if child:IsA("Frame") then
            local icon = child:FindFirstChildOfClass("TextLabel")
            if icon and icon.Text == "⚠️" then
                child:Destroy()
            end
        end
    end
    consoleFrame.CanvasSize = UDim2.new(0, 0, 0, consoleLayout.AbsoluteContentSize.Y + 10)
end)

local function exec(code)
    local fn, err = loadstring(code)
    if not fn then
        addLog("error", "Compile error: " .. tostring(err), "Check for missing brackets, commas, or stray characters.")
        return
    end
    local ok, runtimeErr = pcall(fn)
    if not ok then
        addLog("error", "Runtime error: " .. tostring(runtimeErr), "Something was nil or indexed wrong. Check your variables/instances.")
    else
        addLog("ok", "Script executed successfully.", "")
    end
end

local execButton = Instance.new("TextButton", pageDesign)
execButton.Size = UDim2.new(0, 160, 0, 40)
execButton.Position = UDim2.new(0, 20, 1, -50)
execButton.BackgroundColor3 = Color3.fromRGB(60, 180, 80)
execButton.Text = "EXECUTE"
execButton.TextColor3 = Color3.fromRGB(255, 255, 255)
execButton.Font = Enum.Font.GothamBold
execButton.TextScaled = true
execButton.BorderSizePixel = 0
Instance.new("UICorner", execButton).CornerRadius = UDim.new(0, 10)

execButton.MouseButton1Click:Connect(function()
    local s = editorBox.Text
    if s ~= "" then
        exec(s)
        switchPage("CONSOLE")
    end
end)

local clearButton = Instance.new("TextButton", pageDesign)
clearButton.Size = UDim2.new(0, 160, 0, 40)
clearButton.Position = UDim2.new(1, -180, 1, -50)
clearButton.BackgroundColor3 = Color3.fromRGB(180, 60, 60)
clearButton.Text = "CLEAR"
clearButton.TextColor3 = Color3.fromRGB(255, 255, 255)
clearButton.Font = Enum.Font.GothamBold
clearButton.TextScaled = true
clearButton.BorderSizePixel = 0
Instance.new("UICorner", clearButton).CornerRadius = UDim.new(0, 10)

clearButton.MouseButton1Click:Connect(function()
    editorBox.Text = ""
end)

local function generateScript(prompt)
    local s = prompt:lower()
    if s:find("walkspeed") then
        return [[local p = game:GetService("Players").LocalPlayer
local char = p.Character or p.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
hum.WalkSpeed = 32
print("Local walkspeed set to 32")]]
    end
    if s:find("jump") then
        return [[local p = game:GetService("Players").LocalPlayer
local char = p.Character or p.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
hum.JumpPower = 75
print("Local jump power set to 75")]]
    end
    if s:find("camera") then
        return [[local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(Vector3.new(0,20,-30), Vector3.new(0,0,0))
print("Camera set")]]
    end
    if s:find("gui") or s:find("button") then
        return [[local p = game:GetService("Players").LocalPlayer
local g = Instance.new("ScreenGui", p:WaitForChild("PlayerGui"))
local b = Instance.new("TextButton", g)
b.Size = UDim2.new(0,200,0,50)
b.Position = UDim2.new(0.5,-100,0.5,-25)
b.BackgroundColor3 = Color3.fromRGB(60,120,200)
b.TextColor3 = Color3.fromRGB(255,255,255)
b.Font = Enum.Font.GothamBold
b.TextScaled = true
b.Text = "LOCAL BUTTON"
b.MouseButton1Click:Connect(function()
    print("Clicked")
end)]]
    end

    addLog("warn", "AI could not detect your request.", "Try using words like walkspeed, jump, camera, gui, or button.")
    return "-- CYBIX AI could not detect your request."
end

genButton.MouseButton1Click:Connect(function()
    local scriptText = generateScript(promptBox.Text)
    editorBox.Text = scriptText
    switchPage("SCRIPT DESIGN")
end)

-- HI PAGE
local pageHI = makePage()
pages["Plugins"] = pageHI

local hiTitle = Instance.new("TextLabel", pageHI)
hiTitle.Size = UDim2.new(1, -20, 0, 40)
hiTitle.Position = UDim2.new(0, 10, 0, 10)
hiTitle.BackgroundTransparency = 1
hiTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
hiTitle.Font = Enum.Font.GothamBold
hiTitle.TextScaled = true
hiTitle.Text = "Ok, so i did add my menu to this script for free because i was bored and i just dont feel like aming a paid key rn"

local injectBtn = Instance.new("TextButton", pageHI)
injectBtn.Size = UDim2.new(0, 260, 0, 60)
injectBtn.Position = UDim2.new(0.5, -130, 0.5, -30)
injectBtn.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
injectBtn.Text = "Inject CYBIX MENU"
injectBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
injectBtn.Font = Enum.Font.GothamBold
injectBtn.TextScaled = true
injectBtn.BorderSizePixel = 0
Instance.new("UICorner", injectBtn).CornerRadius = UDim.new(0, 12)

task.spawn(function()
    while injectBtn.Parent do
        for i = 0,1,0.01 do
            injectBtn.BackgroundColor3 = Color3.fromRGB(0, 0, 255 * i)
            task.wait(0.02)
        end
        for i = 0,1,0.01 do
            injectBtn.BackgroundColor3 = Color3.fromRGB(255 * i, 0, 0)
            task.wait(0.02)
        end
        for i = 0,1,0.01 do
            injectBtn.BackgroundColor3 = Color3.fromRGB(255 * i, 255 * i, 255 * i)
            task.wait(0.02)
        end
    end
end)

-- put your full paid script inside this string:
local CYBIX_PAID_SCRIPT = [[-- CYBIX MENU PAID — FULL (Finalized: God Mode added to PVP)
-- Paste this entire LocalScript into StarterGui (do not wrap in loadstring)

-- Services
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")

-- Player refs
local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:FindFirstChild("Humanoid")

-- Base/default multiplier semantics
local baseWalkSpeed = (humanoid and humanoid.WalkSpeed) or 16
local defaultMultiplier = 1.0

-- Runtime state
local runtimeState = {
    activeEffects = {},
    rgbRunning = false,
    galaxyRunning = false,
    petModel = nil,
    noclipEnabled = false,
    flyEnabled = false,
    espEnabled = false,
    nameTagsEnabled = false,
    espObjects = {},
    nameTagObjects = {},
    noclipConn = nil,
    flyObjects = {gyro = nil, vel = nil},
    espColorIndex = 0,
    creditConn = nil,
    walkMultiplier = defaultMultiplier,
    sliderDragging = false,
    -- PVP / aimbot
    aimbotEnabled = false,            -- legacy camera-only aimbot toggle
    playerAimAimbot = false,          -- player+camera aimbot toggle
    aimbotRadius = 120,               -- pixels (default)
    aimbotRadiusMin = 30,
    aimbotRadiusMax = 300,
    aimbotLocking = false,            -- ensure starts false
    aimbotUserOverride = false,
    aimbotLastMousePos = UIS:GetMouseLocation(),
    aimbotCameraTypeBackup = nil,
    aimbotSliderDragging = false,
    -- God Mode
    godMode = false,
    godConn = nil,
    godCharAddedConn = nil,
    godHumChangedConn = nil,
    godPrevAutoLoad = true
}

-- Utility
local function safeDestroy(obj)
    if obj and obj.Parent then
        pcall(function() obj:Destroy() end)
    end
end

local function getCharacter(plr)
    if plr == player then
        return player.Character
    else
        return plr.Character
    end
end

-- Paid tag (local-only)
local function createPaidTagForLocal()
    local c = player.Character
    if not c then return end
    local head = c:FindFirstChild("Head") or c:FindFirstChild("UpperTorso") or c:FindFirstChild("HumanoidRootPart")
    if not head then return end
    if head:FindFirstChild("CybixPaidTag") then head.CybixPaidTag:Destroy() end
    local bg = Instance.new("BillboardGui")
    bg.Name = "CybixPaidTag"
    bg.Adornee = head
    bg.AlwaysOnTop = true
    bg.Size = UDim2.new(0,200,0,30)
    bg.StudsOffset = Vector3.new(0,3.2,0)
    bg.Parent = head

    local label = Instance.new("TextLabel", bg)
    label.Size = UDim2.new(1,0,1,0)
    label.BackgroundTransparency = 1
    label.Text = "< CYBIX MENU USER >"
    label.TextColor3 = Color3.fromRGB(255,215,80)
    label.Font = Enum.Font.GothamBold
    label.TextScaled = true
    label.TextStrokeTransparency = 0.7
    return bg
end

createPaidTagForLocal()
player.CharacterAdded:Connect(function(c)
    char = c
    humanoid = char:FindFirstChild("Humanoid")
    task.wait(0.1)
    createPaidTagForLocal()
end)

-- Noclip
local function enableNoclip()
    runtimeState.noclipEnabled = true
    local c = player.Character
    if c then
        for _, part in ipairs(c:GetDescendants()) do
            if part:IsA("BasePart") then
                if part:GetAttribute("origCanCollide") == nil then
                    part:SetAttribute("origCanCollide", part.CanCollide)
                end
                part.CanCollide = false
            end
        end
    end
    runtimeState.noclipConn = RunService.Stepped:Connect(function()
        local c2 = player.Character
        if c2 then
            for _, part in ipairs(c2:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.CanCollide = false
                end
            end
        end
    end)
end

local function disableNoclip()
    runtimeState.noclipEnabled = false
    if runtimeState.noclipConn then
        runtimeState.noclipConn:Disconnect()
        runtimeState.noclipConn = nil
    end
    local c = player.Character
    if c then
        for _, part in ipairs(c:GetDescendants()) do
            if part:IsA("BasePart") then
                local orig = part:GetAttribute("origCanCollide")
                if orig ~= nil then
                    part.CanCollide = orig
                    part:SetAttribute("origCanCollide", nil)
                else
                    part.CanCollide = true
                end
            end
        end
    end
end

-- Fly
local flySpeed = 50

local function startFly()
    if runtimeState.flyEnabled then return end
    local c = player.Character
    if not c then return end
    local hrp = c:FindFirstChild("HumanoidRootPart")
    if not hrp then return end

    local bodyGyro = Instance.new("BodyGyro")
    bodyGyro.P = 9e4
    bodyGyro.MaxTorque = Vector3.new(9e9,9e9,9e9)
    bodyGyro.CFrame = hrp.CFrame
    bodyGyro.Parent = hrp

    local bodyVel = Instance.new("BodyVelocity")
    bodyVel.MaxForce = Vector3.new(9e9,9e9,9e9)
    bodyVel.Velocity = Vector3.new(0,0,0)
    bodyVel.Parent = hrp

    runtimeState.flyEnabled = true
    runtimeState.flyObjects.gyro = bodyGyro
    runtimeState.flyObjects.vel = bodyVel
end

local function stopFly()
    runtimeState.flyEnabled = false
    safeDestroy(runtimeState.flyObjects.gyro)
    safeDestroy(runtimeState.flyObjects.vel)
    runtimeState.flyObjects.gyro = nil
    runtimeState.flyObjects.vel = nil
end

RunService.Heartbeat:Connect(function()
    if runtimeState.flyEnabled then
        local c = player.Character
        local hrp = c and c:FindFirstChild("HumanoidRootPart")
        if not hrp then return end
        local cam = Workspace.CurrentCamera
        if runtimeState.flyObjects.gyro then
            runtimeState.flyObjects.gyro.CFrame = cam.CFrame
        end
        local move = Vector3.new(0,0,0)
        if UIS:IsKeyDown(Enum.KeyCode.W) then move = move + cam.CFrame.LookVector end
        if UIS:IsKeyDown(Enum.KeyCode.S) then move = move - cam.CFrame.LookVector end
        if UIS:IsKeyDown(Enum.KeyCode.A) then move = move - cam.CFrame.RightVector end
        if UIS:IsKeyDown(Enum.KeyCode.D) then move = move + cam.CFrame.RightVector end
        if UIS:IsKeyDown(Enum.KeyCode.Space) then move = move + Vector3.new(0,1,0) end
        if UIS:IsKeyDown(Enum.KeyCode.LeftShift) then move = move - Vector3.new(0,1,0) end
        if runtimeState.flyObjects.vel then
            if move.Magnitude > 0 then
                runtimeState.flyObjects.vel.Velocity = move.Unit * flySpeed
            else
                runtimeState.flyObjects.vel.Velocity = Vector3.new(0,0,0)
            end
        end
    end
end)

-- Visuals: ESP and NameTags
local function makeHighlightForCharacter(plr)
    local c = getCharacter(plr)
    if not c then return nil end
    local highlight = Instance.new("Highlight")
    highlight.Name = "CybixESP"
    highlight.Adornee = c
    highlight.FillTransparency = 1
    highlight.OutlineTransparency = 0
    highlight.OutlineColor = Color3.fromHSV(0,1,1)
    highlight.Parent = c
    return highlight
end

local function makeNameTagForCharacter(plr)
    local c = getCharacter(plr)
    if not c then return nil end
    local head = c:FindFirstChild("Head") or c:FindFirstChild("UpperTorso") or c:FindFirstChild("HumanoidRootPart")
    if not head then return nil end
    local bg = Instance.new("BillboardGui")
    bg.Name = "CybixNameTag"
    bg.Adornee = head
    bg.AlwaysOnTop = true
    bg.Size = UDim2.new(0,200,0,40)
    bg.StudsOffset = Vector3.new(0,2.4,0)
    bg.Parent = c

    local label = Instance.new("TextLabel", bg)
    label.Size = UDim2.new(1,0,1,0)
    label.BackgroundTransparency = 1
    label.Text = plr.DisplayName or plr.Name
    label.TextColor3 = Color3.fromRGB(255,255,255)
    label.Font = Enum.Font.Gotham
    label.TextScaled = true
    label.TextStrokeTransparency = 0.6
    return bg
end

local function enableESP()
    runtimeState.espEnabled = true
    for _, plr in ipairs(Players:GetPlayers()) do
        if plr ~= player then
            local c = plr.Character
            if c and not runtimeState.espObjects[plr] then
                runtimeState.espObjects[plr] = makeHighlightForCharacter(plr)
            end
        end
    end
    Players.PlayerAdded:Connect(function(plr)
        if runtimeState.espEnabled and plr ~= player then
            runtimeState.espObjects[plr] = makeHighlightForCharacter(plr)
        end
    end)
    Players.PlayerRemoving:Connect(function(plr)
        if runtimeState.espObjects[plr] then
            safeDestroy(runtimeState.espObjects[plr])
            runtimeState.espObjects[plr] = nil
        end
        if runtimeState.nameTagObjects[plr] then
            safeDestroy(runtimeState.nameTagObjects[plr])
            runtimeState.nameTagObjects[plr] = nil
        end
    end)
end

local function disableESP()
    runtimeState.espEnabled = false
    for plr, obj in pairs(runtimeState.espObjects) do
        safeDestroy(obj)
        runtimeState.espObjects[plr] = nil
    end
end

RunService.Heartbeat:Connect(function(dt)
    if runtimeState.espEnabled then
        runtimeState.espColorIndex = (runtimeState.espColorIndex + dt * 0.2) % 1
        local col = Color3.fromHSV(runtimeState.espColorIndex, 1, 1)
        for plr, obj in pairs(runtimeState.espObjects) do
            if obj and obj.Parent then
                obj.OutlineColor = col
            end
        end
    end
end)

local function enableNameTags()
    runtimeState.nameTagsEnabled = true
    for _, plr in ipairs(Players:GetPlayers()) do
        if plr ~= player and not runtimeState.nameTagObjects[plr] then
            runtimeState.nameTagObjects[plr] = makeNameTagForCharacter(plr)
        end
    end
    Players.PlayerAdded:Connect(function(plr)
        if runtimeState.nameTagsEnabled and plr ~= player then
            runtimeState.nameTagObjects[plr] = makeNameTagForCharacter(plr)
        end
    end)
    Players.PlayerRemoving:Connect(function(plr)
        if runtimeState.nameTagObjects[plr] then
            safeDestroy(runtimeState.nameTagObjects[plr])
            runtimeState.nameTagObjects[plr] = nil
        end
    end)
end

local function disableNameTags()
    runtimeState.nameTagsEnabled = false
    for plr, obj in pairs(runtimeState.nameTagObjects) do
        safeDestroy(obj)
        runtimeState.nameTagObjects[plr] = nil
    end
end

Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(c)
        task.wait(0.1)
        if runtimeState.espEnabled and plr ~= player then
            runtimeState.espObjects[plr] = makeHighlightForCharacter(plr)
        end
        if runtimeState.nameTagsEnabled and plr ~= player then
            runtimeState.nameTagObjects[plr] = makeNameTagForCharacter(plr)
        end
    end)
end)

-- =========================
-- Aimbot core (client-side assist)
-- =========================

local function findAimbotTarget(radiusPixels)
    local cam = Workspace.CurrentCamera
    if not cam then return nil end
    local center = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
    local best, bestDist = nil, math.huge
    for _, plr in ipairs(Players:GetPlayers()) do
        if plr ~= player and plr.Character and plr.Character.Parent then
            local head = plr.Character:FindFirstChild("Head") or plr.Character:FindFirstChild("UpperTorso")
            if head then
                local screenPos, onScreen = cam:WorldToViewportPoint(head.Position)
                if onScreen then
                    local sp = Vector2.new(screenPos.X, screenPos.Y)
                    local dist = (sp - center).Magnitude
                    if dist <= radiusPixels and dist < bestDist then
                        best = {player = plr, part = head, screenPos = sp, worldPos = head.Position}
                        bestDist = dist
                    end
                end
            end
        end
    end
    return best
end

-- lock camera to target while right mouse held and aimbot active
local function startAimbotLock()
    if runtimeState.aimbotLocking then return end
    runtimeState.aimbotLocking = true
    runtimeState.aimbotUserOverride = false
    runtimeState.aimbotLastMousePos = UIS:GetMouseLocation()
    local cam = Workspace.CurrentCamera
    if cam then
        runtimeState.aimbotCameraTypeBackup = cam.CameraType
    end
end

local function stopAimbotLock()
    if not runtimeState.aimbotLocking then return end
    runtimeState.aimbotLocking = false
    runtimeState.aimbotUserOverride = false
    local cam = Workspace.CurrentCamera
    if cam and runtimeState.aimbotCameraTypeBackup then
        cam.CameraType = runtimeState.aimbotCameraTypeBackup
        runtimeState.aimbotCameraTypeBackup = nil
    end
end

-- Heartbeat handler to perform camera adjustments when locking
RunService.Heartbeat:Connect(function()
    if (runtimeState.aimbotEnabled or runtimeState.playerAimAimbot)
        and runtimeState.aimbotLocking
        and not runtimeState.aimbotUserOverride then

        local cam = Workspace.CurrentCamera
        if not cam then return end
        local target = findAimbotTarget(runtimeState.aimbotRadius)
        if not target then return end

        -- rotate camera to look at target from current camera position
        local camPos = cam.CFrame.Position
        local lookCFrame = CFrame.new(camPos, target.worldPos)
        cam.CameraType = Enum.CameraType.Scriptable
        cam.CFrame = lookCFrame

        -- If playerAimAimbot is enabled, rotate the player's HumanoidRootPart to face the target
        if runtimeState.playerAimAimbot then
            local c = player.Character
            if c then
                local hrp = c:FindFirstChild("HumanoidRootPart")
                if hrp then
                    -- Keep player's Y position unchanged while facing target
                    local targetPos = Vector3.new(target.worldPos.X, hrp.Position.Y, target.worldPos.Z)
                    hrp.CFrame = CFrame.new(hrp.Position, targetPos)
                end
            end
        end
    end
end)

-- detect mouse movement to allow user override
UIS.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseMovement then
        local pos = UIS:GetMouseLocation()
        local delta = (pos - runtimeState.aimbotLastMousePos).Magnitude
        runtimeState.aimbotLastMousePos = pos
        if runtimeState.aimbotLocking and delta > 2 then
            runtimeState.aimbotUserOverride = true
        end
    end
end)

-- right mouse button handling
local mouse = player:GetMouse()
mouse.Button2Down:Connect(function()
    -- only start locking if aimbot toggles are enabled
    if runtimeState.aimbotEnabled or runtimeState.playerAimAimbot then
        runtimeState.aimbotUserOverride = false
        startAimbotLock()
    end
end)
mouse.Button2Up:Connect(function()
    if runtimeState.aimbotLocking then
        stopAimbotLock()
    end
end)

-- =========================
-- God Mode functions
-- =========================

local function applyGodToHumanoid(hum)
    if not hum then return end
    -- set huge health values
    pcall(function()
        hum.MaxHealth = math.huge
        hum.Health = math.huge
    end)
end

local function enableGodMode()
    if runtimeState.godMode then return end
    runtimeState.godMode = true

    -- remember previous CharacterAutoLoads setting and disable auto respawn
    runtimeState.godPrevAutoLoad = Players.CharacterAutoLoads
    pcall(function() Players.CharacterAutoLoads = false end)

    -- apply to current character
    local c = player.Character
    if c then
        local hum = c:FindFirstChild("Humanoid")
        if hum then
            applyGodToHumanoid(hum)
            -- ensure health stays high
            if runtimeState.godHumChangedConn then
                runtimeState.godHumChangedConn:Disconnect()
                runtimeState.godHumChangedConn = nil
            end
            runtimeState.godHumChangedConn = hum.HealthChanged:Connect(function()
                if runtimeState.godMode and hum and hum.Parent then
                    if hum.Health < math.huge then
                        pcall(function()
                            hum.MaxHealth = math.huge
                            hum.Health = math.huge
                        end)
                    end
                end
            end)
        end
    end

    -- ensure future characters are protected
    if runtimeState.godCharAddedConn then
        runtimeState.godCharAddedConn:Disconnect()
        runtimeState.godCharAddedConn = nil
    end
    runtimeState.godCharAddedConn = player.CharacterAdded:Connect(function(cnew)
        task.wait(0.05)
        local humNew = cnew:FindFirstChild("Humanoid")
        if humNew then
            applyGodToHumanoid(humNew)
            if runtimeState.godHumChangedConn then
                runtimeState.godHumChangedConn:Disconnect()
                runtimeState.godHumChangedConn = nil
            end
            runtimeState.godHumChangedConn = humNew.HealthChanged:Connect(function()
                if runtimeState.godMode and humNew and humNew.Parent then
                    if humNew.Health < math.huge then
                        pcall(function()
                            humNew.MaxHealth = math.huge
                            humNew.Health = math.huge
                        end)
                    end
                end
            end)
        end
    end)

    -- safety heartbeat to enforce health
    if runtimeState.godConn then
        runtimeState.godConn:Disconnect()
        runtimeState.godConn = nil
    end
    runtimeState.godConn = RunService.Heartbeat:Connect(function()
        if not runtimeState.godMode then return end
        local c2 = player.Character
        if c2 then
            local h2 = c2:FindFirstChild("Humanoid")
            if h2 then
                if h2.Health < math.huge then
                    pcall(function()
                        h2.MaxHealth = math.huge
                        h2.Health = math.huge
                    end)
                end
            end
        end
    end)
end

local function disableGodMode()
    if not runtimeState.godMode then return end
    runtimeState.godMode = false

    -- restore CharacterAutoLoads
    pcall(function() Players.CharacterAutoLoads = runtimeState.godPrevAutoLoad end)

    if runtimeState.godConn then
        runtimeState.godConn:Disconnect()
        runtimeState.godConn = nil
    end
    if runtimeState.godHumChangedConn then
        runtimeState.godHumChangedConn:Disconnect()
        runtimeState.godHumChangedConn = nil
    end
    if runtimeState.godCharAddedConn then
        runtimeState.godCharAddedConn:Disconnect()
        runtimeState.godCharAddedConn = nil
    end

    -- restore humanoid to default health values if present
    local c = player.Character
    if c then
        local hum = c:FindFirstChild("Humanoid")
        if hum then
            pcall(function()
                hum.MaxHealth = 100
                hum.Health = math.min(100, hum.Health)
            end)
        end
    end
end

-- =========================
-- GUI: build pages and buttons
-- =========================

-- ROOT GUI
local gui = Instance.new("ScreenGui")
gui.Name = "CybixMiniMenu"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")

-- MAIN WINDOW
local mainFrame = Instance.new("Frame")
mainFrame.Size = UDim2.new(0,460,0,460)
mainFrame.Position = UDim2.new(0,40,0.5,-230)
mainFrame.BackgroundColor3 = Color3.fromRGB(20,20,24)
mainFrame.BorderSizePixel = 0
mainFrame.Active = true
mainFrame.Parent = gui
Instance.new("UICorner", mainFrame).CornerRadius = UDim.new(0,12)

-- HEADER (drag handle)
local header = Instance.new("Frame", mainFrame)
header.Size = UDim2.new(1,0,0,40)
header.BackgroundColor3 = Color3.fromRGB(28,28,34)
header.BorderSizePixel = 0
Instance.new("UICorner", header).CornerRadius = UDim.new(0,12)

local title = Instance.new("TextLabel", header)
title.Size = UDim2.new(0,260,1,0)
title.Position = UDim2.new(0,12,0,0)
title.BackgroundTransparency = 1
title.Text = "CYBIX MENU PAID"
title.TextColor3 = Color3.fromRGB(245,245,245)
title.Font = Enum.Font.GothamBold
title.TextScaled = true
title.TextXAlignment = Enum.TextXAlignment.Left

-- RESET X BUTTON
local closeBtn = Instance.new("TextButton", header)
closeBtn.Size = UDim2.new(0,40,0,32)
closeBtn.Position = UDim2.new(1,-52,0,4)
closeBtn.BackgroundColor3 = Color3.fromRGB(160,40,40)
closeBtn.Text = "X"
closeBtn.TextColor3 = Color3.fromRGB(255,255,255)
closeBtn.Font = Enum.Font.GothamBold
closeBtn.TextScaled = true
closeBtn.BorderSizePixel = 0
Instance.new("UICorner", closeBtn).CornerRadius = UDim.new(0,8)

closeBtn.MouseButton1Click:Connect(function()
    -- destroy GUI and attempt to clean up runtime state
    runtimeState.rgbRunning = false
    runtimeState.galaxyRunning = false
    stopFly()
    disableNoclip()
    disableESP()
    disableNameTags()
    disableGodMode()
    safeDestroy(gui)
end)

-- Make header draggable
do
    local dragging, dragInput, dragStart, startPos
    header.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            dragging = true
            dragStart = input.Position
            startPos = mainFrame.Position
            input.Changed:Connect(function()
                if input.UserInputState == Enum.UserInputState.End then
                    dragging = false
                end
            end)
        end
    end)
    header.InputChanged:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement then
            dragInput = input
        end
    end)
    RunService.RenderStepped:Connect(function()
        if dragging and dragInput then
            local delta = dragInput.Position - dragStart
            mainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
        end
    end)
end

-- SIDEBAR
local sidebar = Instance.new("Frame", mainFrame)
sidebar.Size = UDim2.new(0,120,1,-104)
sidebar.Position = UDim2.new(0,0,0,40)
sidebar.BackgroundColor3 = Color3.fromRGB(18,18,22)
sidebar.BorderSizePixel = 0
Instance.new("UICorner", sidebar).CornerRadius = UDim.new(0,10)

local sidebarLayout = Instance.new("UIListLayout", sidebar)
sidebarLayout.Padding = UDim.new(0,8)
sidebarLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
sidebarLayout.SortOrder = Enum.SortOrder.LayoutOrder

-- CONTENT FRAME
local contentFrame = Instance.new("Frame", mainFrame)
contentFrame.Size = UDim2.new(1,-140,1,-104)
contentFrame.Position = UDim2.new(0,140,0,40)
contentFrame.BackgroundColor3 = Color3.fromRGB(24,24,30)
contentFrame.BorderSizePixel = 0
Instance.new("UICorner", contentFrame).CornerRadius = UDim.new(0,10)

local pages = {}
local currentPage

local function createPage()
    local page = Instance.new("ScrollingFrame", contentFrame)
    page.Size = UDim2.new(1,-16,1,-16)
    page.Position = UDim2.new(0,8,0,8)
    page.BackgroundTransparency = 1
    page.ScrollBarThickness = 6
    page.Visible = false
    local layout = Instance.new("UIListLayout", page)
    layout.Padding = UDim.new(0,8)
    layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
        page.CanvasSize = UDim2.new(0,0,0,layout.AbsoluteContentSize.Y + 12)
    end)
    return page
end

local function switchPage(name)
    if currentPage then currentPage.Visible = false end
    currentPage = pages[name]
    if currentPage then currentPage.Visible = true end
end

local function createSidebarButton(name, order)
    local btn = Instance.new("TextButton", sidebar)
    btn.Size = UDim2.new(1,-12,0,32)
    btn.LayoutOrder = order or 1
    btn.BackgroundColor3 = Color3.fromRGB(40,40,50)
    btn.TextColor3 = Color3.fromRGB(220,220,240)
    btn.Font = Enum.Font.GothamBold
    btn.TextScaled = true
    btn.Text = name
    btn.BorderSizePixel = 0
    Instance.new("UICorner", btn).CornerRadius = UDim.new(0,8)
    btn.MouseEnter:Connect(function()
        TweenService:Create(btn, TweenInfo.new(0.12), {BackgroundColor3 = Color3.fromRGB(70,70,90)}):Play()
    end)
    btn.MouseLeave:Connect(function()
        TweenService:Create(btn, TweenInfo.new(0.12), {BackgroundColor3 = Color3.fromRGB(40,40,50)}):Play()
    end)
    return btn
end

local function createSection(page, titleText, height)
    local section = Instance.new("Frame", page)
    section.Size = UDim2.new(1,-8,0,height or 140)
    section.BackgroundColor3 = Color3.fromRGB(32,32,40)
    section.BorderSizePixel = 0
    Instance.new("UICorner", section).CornerRadius = UDim.new(0,8)
    local title = Instance.new("TextLabel", section)
    title.Size = UDim2.new(1,-16,0,28)
    title.Position = UDim2.new(0,8,0,6)
    title.BackgroundTransparency = 1
    title.Text = titleText
    title.TextColor3 = Color3.fromRGB(240,240,240)
    title.Font = Enum.Font.GothamBold
    title.TextScaled = true
    local layout = Instance.new("UIListLayout", section)
    layout.Padding = UDim.new(0,6)
    layout.SortOrder = Enum.SortOrder.LayoutOrder
    return section
end

local function createButton(parent, text)
    local btn = Instance.new("TextButton", parent)
    btn.Size = UDim2.new(1,-16,0,34)
    btn.Position = UDim2.new(0,8,0,0)
    btn.BackgroundColor3 = Color3.fromRGB(50,50,60)
    btn.TextColor3 = Color3.fromRGB(255,255,255)
    btn.Font = Enum.Font.Gotham
    btn.TextScaled = true
    btn.Text = text
    btn.BorderSizePixel = 0
    Instance.new("UICorner", btn).CornerRadius = UDim.new(0,8)
    btn.MouseEnter:Connect(function()
        TweenService:Create(btn, TweenInfo.new(0.12), {BackgroundColor3 = Color3.fromRGB(70,70,90)}):Play()
    end)
    btn.MouseLeave:Connect(function()
        TweenService:Create(btn, TweenInfo.new(0.12), {BackgroundColor3 = Color3.fromRGB(50,50,60)}):Play()
    end)
    return btn
end

-- Leaderboard
local lbPage = createPage()
pages["Leaderboard"] = lbPage

local lbBtn = createSidebarButton("Leaderboard", 1)
lbBtn.MouseButton1Click:Connect(function() switchPage("Leaderboard") end)

local lbSection = createSection(lbPage, "Players", 220)
local lbList = Instance.new("ScrollingFrame", lbSection)
lbList.Size = UDim2.new(1,-20,0,160)
lbList.Position = UDim2.new(0,10,0,44)
lbList.BackgroundTransparency = 1
lbList.ScrollBarThickness = 6
local lbLayout = Instance.new("UIListLayout", lbList)
lbLayout.Padding = UDim.new(0,4)

local function clearLeaderboard()
    for _,v in ipairs(lbList:GetChildren()) do
        if v:IsA("TextLabel") then v:Destroy() end
    end
end

local function addPlayerToLeaderboard(plr)
    local item = Instance.new("TextLabel", lbList)
    item.Size = UDim2.new(1,-10,0,28)
    item.BackgroundColor3 = Color3.fromRGB(45,45,55)
    item.TextColor3 = Color3.fromRGB(255,255,255)
    item.Font = Enum.Font.Gotham
    item.TextScaled = true
    item.Text = plr.Name
    Instance.new("UICorner", item).CornerRadius = UDim.new(0,8)
end

clearLeaderboard()
for _,plr in ipairs(Players:GetPlayers()) do addPlayerToLeaderboard(plr) end
Players.PlayerAdded:Connect(function(plr) addPlayerToLeaderboard(plr) end)
Players.PlayerRemoving:Connect(function()
    clearLeaderboard()
    for _,p in ipairs(Players:GetPlayers()) do addPlayerToLeaderboard(p) end
end)

-- Settings
local setPage = createPage()
pages["Settings"] = setPage

local setBtn = createSidebarButton("Settings", 2)
setBtn.MouseButton1Click:Connect(function() switchPage("Settings") end)

local setSection = createSection(setPage, "Themes", 140)
local defaultBtn = createButton(setSection, "Default Theme")
local rgbBtn = createButton(setSection, "RGB Theme")
local galaxyBtn = createButton(setSection, "Galaxy Theme")

defaultBtn.MouseButton1Click:Connect(function()
    runtimeState.rgbRunning = false
    runtimeState.galaxyRunning = false
    mainFrame.BackgroundColor3 = Color3.fromRGB(20,20,24)
    contentFrame.BackgroundColor3 = Color3.fromRGB(24,24,30)
    sidebar.BackgroundColor3 = Color3.fromRGB(18,18,22)
end)

rgbBtn.MouseButton1Click:Connect(function()
    runtimeState.rgbRunning = true
    runtimeState.galaxyRunning = false
    task.spawn(function()
        while runtimeState.rgbRunning do
            for i=0,1,0.02 do
                if not runtimeState.rgbRunning then break end
                mainFrame.BackgroundColor3 = Color3.fromHSV(i,0.6,0.9)
                task.wait(0.03)
            end
        end
    end)
end)

galaxyBtn.MouseButton1Click:Connect(function()
    runtimeState.rgbRunning = false
    runtimeState.galaxyRunning = true
    task.spawn(function()
        while runtimeState.galaxyRunning do
            for i=0,1,0.02 do
                if not runtimeState.galaxyRunning then break end
                mainFrame.BackgroundColor3 = Color3.fromHSV(0.7 + i*0.1, 0.7, 0.9)
                task.wait(0.03)
            end
        end
    end)
end)

-- Fun
local funPage = createPage()
pages["Fun"] = funPage

local funBtn = createSidebarButton("Fun", 3)
funBtn.MouseButton1Click:Connect(function() switchPage("Fun") end)

local fxSection = createSection(funPage, "Effects", 160)
local sparkBtn = createButton(fxSection, "Sparkles")
local rainbowBtn = createButton(fxSection, "Rainbow Body")
local auraBtn = createButton(fxSection, "Glow Aura")

sparkBtn.MouseButton1Click:Connect(function()
    local hrp = char and char:FindFirstChild("HumanoidRootPart")
    if hrp then
        local s = Instance.new("Sparkles", hrp)
        table.insert(runtimeState.activeEffects, s)
        task.delay(6, function() safeDestroy(s) end)
    end
end)

rainbowBtn.MouseButton1Click:Connect(function()
    task.spawn(function()
        for i=0,1,0.02 do
            for _,part in ipairs(char:GetChildren()) do
                if part:IsA("BasePart") then
                    part.Color = Color3.fromHSV(i,1,1)
                end
            end
            task.wait(0.03)
        end
    end)
end)

auraBtn.MouseButton1Click:Connect(function()
    local hrp = char and char:FindFirstChild("HumanoidRootPart")
    if hrp then
        local light = Instance.new("PointLight", hrp)
        light.Range = 14
        light.Brightness = 2
        light.Color = Color3.fromRGB(0,150,255)
        table.insert(runtimeState.activeEffects, light)
        task.delay(6, function() safeDestroy(light) end)
    end
end)

local emoteSection = createSection(funPage, "Emotes", 120)
local danceBtn = createButton(emoteSection, "Dance")
local waveBtn = createButton(emoteSection, "Wave")

local function playAnim(id)
    if not humanoid then return end
    local anim = Instance.new("Animation")
    anim.AnimationId = "rbxassetid://" .. tostring(id)
    local ok, track = pcall(function() return humanoid:LoadAnimation(anim) end)
    if ok and track then
        track:Play()
        task.delay(6, function()
            if track.IsPlaying then track:Stop() end
        end)
    end
end

danceBtn.MouseButton1Click:Connect(function() playAnim(507771019) end)
waveBtn.MouseButton1Click:Connect(function() playAnim(507770239) end)

-- Movement tab
local movePage = createPage()
pages["Movement"] = movePage

local moveBtn = createSidebarButton("Movement", 4)
moveBtn.MouseButton1Click:Connect(function() switchPage("Movement") end)

local moveSection = createSection(movePage, "Movement", 240)
local noclipToggle = createButton(moveSection, "Noclip: OFF")
local flyToggle = createButton(moveSection, "Fly: OFF")

noclipToggle.MouseButton1Click:Connect(function()
    if runtimeState.noclipEnabled then
        disableNoclip()
        noclipToggle.Text = "Noclip: OFF"
    else
        enableNoclip()
        noclipToggle.Text = "Noclip: ON"
    end
end)

flyToggle.MouseButton1Click:Connect(function()
    if runtimeState.flyEnabled then
        stopFly()
        flyToggle.Text = "Fly: OFF"
    else
        startFly()
        flyToggle.Text = "Fly: ON"
    end
end)

-- Walk Speed Slider UI
local sliderLabel = Instance.new("TextLabel", moveSection)
sliderLabel.Size = UDim2.new(1,-16,0,22)
sliderLabel.Position = UDim2.new(0,8,0,44)
sliderLabel.BackgroundTransparency = 1
sliderLabel.Text = "Walk Speed Multiplier: " .. string.format("%.2f", runtimeState.walkMultiplier) .. "x"
sliderLabel.TextColor3 = Color3.fromRGB(230,230,230)
sliderLabel.Font = Enum.Font.Gotham
sliderLabel.TextSize = 14
sliderLabel.TextXAlignment = Enum.TextXAlignment.Left

local sliderBar = Instance.new("Frame", moveSection)
sliderBar.Size = UDim2.new(1,-32,0,14)
sliderBar.Position = UDim2.new(0,16,0,72)
sliderBar.BackgroundColor3 = Color3.fromRGB(60,60,70)
sliderBar.BorderSizePixel = 0
Instance.new("UICorner", sliderBar).CornerRadius = UDim.new(0,6)

local sliderFill = Instance.new("Frame", sliderBar)
sliderFill.Size = UDim2.new( (runtimeState.walkMultiplier - 0.1) / (100 - 0.1), 0, 1, 0)
sliderFill.BackgroundColor3 = Color3.fromRGB(100,160,255)
sliderFill.BorderSizePixel = 0
Instance.new("UICorner", sliderFill).CornerRadius = UDim.new(0,6)

local knob = Instance.new("ImageButton", sliderBar)
knob.Size = UDim2.new(0,18,0,18)
knob.Position = UDim2.new(sliderFill.Size.X.Scale, -9, 0.5, -9)
knob.BackgroundTransparency = 1
knob.Image = "rbxassetid://3570695787"
knob.ImageColor3 = Color3.fromRGB(200,200,200)

-- Slider parameters
local sliderMin = 0.1
local sliderMax = 100

local function setWalkMultiplierFromPosition(x)
    local absX = math.clamp(x, 0, sliderBar.AbsoluteSize.X)
    local t = absX / sliderBar.AbsoluteSize.X
    local value = sliderMin + (sliderMax - sliderMin) * t
    runtimeState.walkMultiplier = value
    local h = player.Character and player.Character:FindFirstChild("Humanoid")
    if h then
        h.WalkSpeed = baseWalkSpeed * runtimeState.walkMultiplier
    end
    sliderFill.Size = UDim2.new(t, 0, 1, 0)
    knob.Position = UDim2.new(t, -9, 0.5, -9)
    sliderLabel.Text = "Walk Speed Multiplier: " .. string.format("%.2f", runtimeState.walkMultiplier) .. "x"
end

-- Initialize slider to default multiplier
do
    local t = (runtimeState.walkMultiplier - sliderMin) / (sliderMax - sliderMin)
    sliderFill.Size = UDim2.new(t, 0, 1, 0)
    knob.Position = UDim2.new(t, -9, 0.5, -9)
    if humanoid then
        humanoid.WalkSpeed = baseWalkSpeed * runtimeState.walkMultiplier
    end
end

-- Drag handling
knob.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        runtimeState.sliderDragging = true
        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                runtimeState.sliderDragging = false
            end
        end)
    end
end)

UIS.InputChanged:Connect(function(input)
    if runtimeState.sliderDragging and input.UserInputType == Enum.UserInputType.MouseMovement then
        local relative = input.Position.X - sliderBar.AbsolutePosition.X
        setWalkMultiplierFromPosition(relative)
    end
end)	

-- PVP tab
local pvpPage = createPage()
pages["PVP"] = pvpPage

local pvpBtn = createSidebarButton("PVP", 5)
pvpBtn.MouseButton1Click:Connect(function() switchPage("PVP") end)

local pvpSection = createSection(pvpPage, "PVP", 260)

-- Legacy Aimbot Toggle (camera-only)
local legacyAimbotBtn = createButton(pvpSection, "Legacy Aimbot: OFF")
legacyAimbotBtn.MouseButton1Click:Connect(function()
    runtimeState.aimbotEnabled = not runtimeState.aimbotEnabled
    legacyAimbotBtn.Text = "Legacy Aimbot: " .. (runtimeState.aimbotEnabled and "ON" or "OFF")
    -- overlay visibility: show only when either toggle is ON
    if gui:FindFirstChild("AimbotOverlay") then
        gui.AimbotOverlay.Enabled = (runtimeState.aimbotEnabled or runtimeState.playerAimAimbot)
    end
    -- if both toggles are OFF, ensure lock is stopped
    if not runtimeState.aimbotEnabled and not runtimeState.playerAimAimbot then
        stopAimbotLock()
    end
end)

-- NEW: Aimbot (Player Aim) Toggle
local playerAimToggle = createButton(pvpSection, "Aimbot (Player Aim): OFF")
playerAimToggle.MouseButton1Click:Connect(function()
    runtimeState.playerAimAimbot = not runtimeState.playerAimAimbot
    playerAimToggle.Text = "Aimbot (Player Aim): " .. (runtimeState.playerAimAimbot and "ON" or "OFF")
    -- overlay visibility: show only when either toggle is ON
    if gui:FindFirstChild("AimbotOverlay") then
        gui.AimbotOverlay.Enabled = (runtimeState.aimbotEnabled or runtimeState.playerAimAimbot)
    end
    -- if both toggles are OFF, ensure lock is stopped
    if not runtimeState.aimbotEnabled and not runtimeState.playerAimAimbot then
        stopAimbotLock()
    end
end)

-- God Mode Toggle (added to PVP)
local godBtn = createButton(pvpSection, "God Mode: OFF")
godBtn.MouseButton1Click:Connect(function()
    if runtimeState.godMode then
        disableGodMode()
        godBtn.Text = "God Mode: OFF"
    else
        enableGodMode()
        godBtn.Text = "God Mode: ON"
    end
end)

-- Aimbot radius slider (thin slider, visible circle outline + red dot)
local aimbotSliderLabel = Instance.new("TextLabel", pvpSection)
aimbotSliderLabel.Size = UDim2.new(1,-16,0,18)
aimbotSliderLabel.Position = UDim2.new(0,8,0,170)
aimbotSliderLabel.BackgroundTransparency = 1
aimbotSliderLabel.Text = "Aimbot Radius: " .. tostring(runtimeState.aimbotRadius)
aimbotSliderLabel.TextColor3 = Color3.fromRGB(220,220,220)
aimbotSliderLabel.Font = Enum.Font.Gotham
aimbotSliderLabel.TextSize = 14
aimbotSliderLabel.TextXAlignment = Enum.TextXAlignment.Left

local aimbotSliderBar = Instance.new("Frame", pvpSection)
aimbotSliderBar.Size = UDim2.new(1,-32,0,10)
aimbotSliderBar.Position = UDim2.new(0,16,0,192)
aimbotSliderBar.BackgroundColor3 = Color3.fromRGB(60,60,70)
aimbotSliderBar.BorderSizePixel = 0
Instance.new("UICorner", aimbotSliderBar).CornerRadius = UDim.new(0,6)

local aimbotSliderFill = Instance.new("Frame", aimbotSliderBar)
local initialT = (runtimeState.aimbotRadius - runtimeState.aimbotRadiusMin) / (runtimeState.aimbotRadiusMax - runtimeState.aimbotRadiusMin)
aimbotSliderFill.Size = UDim2.new(initialT, 0, 1, 0)
aimbotSliderFill.BackgroundColor3 = Color3.fromRGB(255,100,100)
aimbotSliderFill.BorderSizePixel = 0
Instance.new("UICorner", aimbotSliderFill).CornerRadius = UDim.new(0,6)

local aimbotKnob = Instance.new("ImageButton", aimbotSliderBar)
aimbotKnob.Size = UDim2.new(0,14,0,14)
aimbotKnob.Position = UDim2.new(aimbotSliderFill.Size.X.Scale, -7, 0.5, -7)
aimbotKnob.BackgroundTransparency = 1
aimbotKnob.Image = "rbxassetid://3570695787"
aimbotKnob.ImageColor3 = Color3.fromRGB(200,200,200)

local function setAimbotRadiusFromPosition(x)
    local absX = math.clamp(x, 0, aimbotSliderBar.AbsoluteSize.X)
    local t = absX / aimbotSliderBar.AbsoluteSize.X
    local value = math.floor(runtimeState.aimbotRadiusMin + (runtimeState.aimbotRadiusMax - runtimeState.aimbotRadiusMin) * t + 0.5)
    runtimeState.aimbotRadius = value
    aimbotSliderFill.Size = UDim2.new(t, 0, 1, 0)
    aimbotKnob.Position = UDim2.new(t, -7, 0.5, -7)
    aimbotSliderLabel.Text = "Aimbot Radius: " .. tostring(runtimeState.aimbotRadius)
    -- update visible circle size if overlay exists
    if gui:FindFirstChild("AimbotOverlay") then
        local overlay = gui.AimbotOverlay
        local circle = overlay:FindFirstChild("AimbotCircle")
        if circle then
            local r = runtimeState.aimbotRadius
            circle.Size = UDim2.new(0, r*2, 0, r*2)
            circle.Position = UDim2.new(0.5, -r, 0.5, -r)
        end
    end
end

aimbotKnob.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        runtimeState.aimbotSliderDragging = true
        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                runtimeState.aimbotSliderDragging = false
            end
        end)
    end
end)

UIS.InputChanged:Connect(function(input)
    if runtimeState.aimbotSliderDragging and input.UserInputType == Enum.UserInputType.MouseMovement then
        local relative = input.Position.X - aimbotSliderBar.AbsolutePosition.X
        setAimbotRadiusFromPosition(relative)
    end
end)

-- Visuals tab (ESP + NameTags should be here)
local visPage = createPage()
pages["Visuals"] = visPage

local visBtn = createSidebarButton("Visuals", 6)
visBtn.MouseButton1Click:Connect(function() switchPage("Visuals") end)

local visSection = createSection(visPage, "Visuals", 160)
local espToggleBtn = createButton(visSection, "ESP: OFF")
espToggleBtn.MouseButton1Click:Connect(function()
    if runtimeState.espEnabled then
        disableESP()
        espToggleBtn.Text = "ESP: OFF"
    else
        enableESP()
        espToggleBtn.Text = "ESP: ON"
    end
end)

local nameTagToggleBtn = createButton(visSection, "NameTags: OFF")
nameTagToggleBtn.MouseButton1Click:Connect(function()
    if runtimeState.nameTagsEnabled then
        disableNameTags()
        nameTagToggleBtn.Text = "NameTags: OFF"
    else
        enableNameTags()
        nameTagToggleBtn.Text = "NameTags: ON"
    end
end)

-- README tab (updated notice text; red bold)
local readmePage = createPage()
pages["README"] = readmePage

local readmeBtn = createSidebarButton("README", 7)
readmeBtn.MouseButton1Click:Connect(function() switchPage("README") end)

local readmeSection = createSection(readmePage, "README", 220)
local readmeLabel = Instance.new("TextLabel", readmeSection)
readmeLabel.Size = UDim2.new(1,-16,0,160)
readmeLabel.Position = UDim2.new(0,8,0,44)
readmeLabel.BackgroundTransparency = 1
readmeLabel.TextColor3 = Color3.fromRGB(255,0,0) -- red bold text color
readmeLabel.Font = Enum.Font.GothamBold
readmeLabel.TextSize = 16
readmeLabel.TextWrapped = true
readmeLabel.Text = ". *NOTICE MODS ARE RECORDED TO BE DETECTED, EVERY SCRIPT FOR ROBLOX IS*"

-- Credits tab (updated text and RGB cycling text; credits text slightly larger and RGB)
local creditsPage = createPage()
pages["Credits"] = creditsPage

local creditsBtn = createSidebarButton("Credits", 8)
creditsBtn.MouseButton1Click:Connect(function() switchPage("Credits") end)

local creditsSection = createSection(creditsPage, "Credits", 160)
local creditsLabel = Instance.new("TextLabel", creditsSection)
creditsLabel.Size = UDim2.new(1,-16,0,120)
creditsLabel.Position = UDim2.new(0,8,0,44)
creditsLabel.BackgroundTransparency = 1
creditsLabel.TextColor3 = Color3.fromRGB(255,255,255)
creditsLabel.Font = Enum.Font.GothamBold
creditsLabel.TextSize = 16
creditsLabel.TextWrapped = true
creditsLabel.Text = "- Desgins and Scripts by CYBIX (jffx99)             -some ideas from BRYAN."

-- Add RGB cycling small header text in credits (restored)
local creditsRGB = Instance.new("TextLabel", creditsSection)
creditsRGB.Size = UDim2.new(1,-16,0,24)
creditsRGB.Position = UDim2.new(0,8,0,8)
creditsRGB.BackgroundTransparency = 1
creditsRGB.Text = "CYBIX CREDITS"
creditsRGB.Font = Enum.Font.GothamBold
creditsRGB.TextScaled = true
creditsRGB.TextColor3 = Color3.fromRGB(255,0,0)

-- RGB cycle for credits header and creditsLabel (creditsLabel will also cycle slowly)
task.spawn(function()
    while creditsRGB and creditsRGB.Parent do
        for i=0,1,0.01 do
            local col = Color3.fromHSV(i, 0.9, 1)
            creditsRGB.TextColor3 = col
            creditsLabel.TextColor3 = col
            task.wait(0.02)
        end
    end
end)
----------------------------------------------------------------
-- MINI GAMES TAB (Layout fixes + more sentences)
-- Paste this block into your menu script after createPage/createSidebarButton/createSection
----------------------------------------------------------------

local mgPage = createPage()
pages["Mini Games"] = mgPage

local mgBtn = createSidebarButton("Mini Games", 98)
mgBtn.MouseButton1Click:Connect(function() switchPage("Mini Games") end)

local mgSection = createSection(mgPage, "Mini Games Hub", 520)

-- Ensure runtimeState fields exist
runtimeState.miniCoins = runtimeState.miniCoins or 0        -- coins earned from memory game
runtimeState.clickerClicks = runtimeState.clickerClicks or 0
runtimeState.clickerValue = runtimeState.clickerValue or 1 -- clicks per manual click
runtimeState.autoClickRate = runtimeState.autoClickRate or 0 -- clicks per second from autos
runtimeState.autoClickAccumulator = runtimeState.autoClickAccumulator or 0

----------------------------------------------------------------
-- Top-right coin display (for the page)
----------------------------------------------------------------
local coinLabel = Instance.new("TextLabel", mgSection)
coinLabel.Size = UDim2.new(0,120,0,28)
coinLabel.Position = UDim2.new(1,-132,0,8)
coinLabel.BackgroundColor3 = Color3.fromRGB(40,40,48)
coinLabel.TextColor3 = Color3.fromRGB(255,215,80)
coinLabel.Font = Enum.Font.GothamBold
coinLabel.TextSize = 14
coinLabel.Text = "Coins: " .. tostring(runtimeState.miniCoins)
coinLabel.TextScaled = false
coinLabel.BorderSizePixel = 0
Instance.new("UICorner", coinLabel).CornerRadius = UDim.new(0,6)

local function updateCoinLabel()
    coinLabel.Text = "Coins: " .. tostring(runtimeState.miniCoins)
end

----------------------------------------------------------------
-- MEMORY / TYPING GAME (unchanged layout, added sentences)
----------------------------------------------------------------

local memFrame = Instance.new("Frame", mgSection)
memFrame.Size = UDim2.new(1,-16,0,160)
memFrame.Position = UDim2.new(0,8,0,44)
memFrame.BackgroundColor3 = Color3.fromRGB(34,34,40)
memFrame.BorderSizePixel = 0
Instance.new("UICorner", memFrame).CornerRadius = UDim.new(0,8)

local memTitle = Instance.new("TextLabel", memFrame)
memTitle.Size = UDim2.new(1,-16,0,28)
memTitle.Position = UDim2.new(0,8,0,6)
memTitle.BackgroundTransparency = 1
memTitle.Text = "Memory Typing"
memTitle.TextColor3 = Color3.fromRGB(230,230,230)
memTitle.Font = Enum.Font.GothamBold
memTitle.TextScaled = true

local memDisplay = Instance.new("TextLabel", memFrame)
memDisplay.Size = UDim2.new(1,-16,0,48)
memDisplay.Position = UDim2.new(0,8,0,44)
memDisplay.BackgroundTransparency = 1
memDisplay.TextColor3 = Color3.fromRGB(200,200,220)
memDisplay.Font = Enum.Font.Gotham
memDisplay.TextSize = 18
memDisplay.TextWrapped = true
memDisplay.Text = "Press Start to play"
memDisplay.TextXAlignment = Enum.TextXAlignment.Center
memDisplay.TextYAlignment = Enum.TextYAlignment.Center

local memInput = Instance.new("TextBox", memFrame)
memInput.Size = UDim2.new(1,-16,0,28)
memInput.Position = UDim2.new(0,8,0,100)
memInput.BackgroundColor3 = Color3.fromRGB(45,45,55)
memInput.TextColor3 = Color3.fromRGB(240,240,240)
memInput.Font = Enum.Font.Gotham
memInput.TextSize = 14
memInput.PlaceholderText = "Type the sentence exactly..."
memInput.ClearTextOnFocus = false
Instance.new("UICorner", memInput).CornerRadius = UDim.new(0,6)

local memStartBtn = Instance.new("TextButton", memFrame)
memStartBtn.Size = UDim2.new(0,100,0,28)
memStartBtn.Position = UDim2.new(1,-108,0,100)
memStartBtn.BackgroundColor3 = Color3.fromRGB(70,70,90)
memStartBtn.TextColor3 = Color3.fromRGB(255,255,255)
memStartBtn.Font = Enum.Font.GothamBold
memStartBtn.TextSize = 14
memStartBtn.Text = "Start"
Instance.new("UICorner", memStartBtn).CornerRadius = UDim.new(0,6)

local memFeedback = Instance.new("TextLabel", memFrame)
memFeedback.Size = UDim2.new(1,-16,0,20)
memFeedback.Position = UDim2.new(0,8,0,132)
memFeedback.BackgroundTransparency = 1
memFeedback.TextColor3 = Color3.fromRGB(180,255,180)
memFeedback.Font = Enum.Font.Gotham
memFeedback.TextSize = 14
memFeedback.Text = ""

-- Sentences pool (expanded)
local memSentences = {
    "Roblox devs ship updates weekly",
    "Space is mostly empty but full of wonders",
    "Dinosaurs once ruled the land",
    "Lua is lightweight and fast",
    "Practice makes your code cleaner",
    "Keep your UI simple and readable",
    "Test in Studio before publishing",
    "Save often and use version control",
    "Be kind to your fellow devs",
    "Small steps lead to big progress",
    "Always comment tricky parts of your code",
    "Use modules to organize large systems",
    "Playtesting finds the weirdest bugs",
    "Balance is key for fun gameplay",
    "Optimize only after profiling",
    "Use descriptive variable names",
    "Backups save a lot of headaches",
    "Iterate fast, polish slowly",
    "Learn from other creators respectfully",
    "Celebrate small wins with your team"
}

local memCurrent = nil
local memShowing = false
local memHideDelay = 2 -- seconds before sentence disappears
local memTimerConn = nil

local function startMemoryRound()
    if memShowing then
        memFeedback.Text = "Round already in progress"
        return
    end
    memInput.Text = ""
    memFeedback.Text = ""
    memCurrent = memSentences[math.random(1,#memSentences)]
    memDisplay.Text = memCurrent
    memShowing = true

    -- hide after delay
    if memTimerConn then memTimerConn:Disconnect() memTimerConn = nil end
    local t0 = tick()
    memTimerConn = RunService.Heartbeat:Connect(function()
        if tick() - t0 >= memHideDelay then
            memDisplay.Text = "" -- sentence disappears
            memTimerConn:Disconnect()
            memTimerConn = nil
        end
    end)
end

local function submitMemoryAttempt()
    if not memCurrent then
        memFeedback.Text = "Start a round first"
        return
    end
    local attempt = tostring(memInput.Text or "")
    local function trim(s) return s:match("^%s*(.-)%s*$") end
    if trim(attempt) == trim(memCurrent) then
        runtimeState.miniCoins = runtimeState.miniCoins + 1
        updateCoinLabel()
        memFeedback.TextColor3 = Color3.fromRGB(180,255,180)
        memFeedback.Text = "Perfect! +1 coin"
    else
        memFeedback.TextColor3 = Color3.fromRGB(255,140,140)
        memFeedback.Text = "Not exact. Try again!"
    end
    memCurrent = nil
    memShowing = false
    memDisplay.Text = "Press Start to play"
end

memStartBtn.MouseButton1Click:Connect(startMemoryRound)
memInput.FocusLost:Connect(function(enter)
    if enter then submitMemoryAttempt() end
end)

----------------------------------------------------------------
-- CLICKER GAME (click area above, upgrades below in scrollable area)
----------------------------------------------------------------

-- Click area (compact to leave room for upgrades below)
local clickFrame = Instance.new("Frame", mgSection)
clickFrame.Size = UDim2.new(1,-16,0,140)
clickFrame.Position = UDim2.new(0,8,0,216)
clickFrame.BackgroundColor3 = Color3.fromRGB(34,34,40)
clickFrame.BorderSizePixel = 0
Instance.new("UICorner", clickFrame).CornerRadius = UDim.new(0,8)

local clickTitle = Instance.new("TextLabel", clickFrame)
clickTitle.Size = UDim2.new(1,-16,0,28)
clickTitle.Position = UDim2.new(0,8,0,6)
clickTitle.BackgroundTransparency = 1
clickTitle.Text = "Clicker"
clickTitle.TextColor3 = Color3.fromRGB(230,230,230)
clickTitle.Font = Enum.Font.GothamBold
clickTitle.TextScaled = true

local clickButton = Instance.new("TextButton", clickFrame)
clickButton.Size = UDim2.new(0,160,0,80)
clickButton.Position = UDim2.new(0.5,-80,0,44)
clickButton.BackgroundColor3 = Color3.fromRGB(70,70,110)
clickButton.TextColor3 = Color3.fromRGB(255,255,255)
clickButton.Font = Enum.Font.GothamBold
clickButton.TextSize = 20
clickButton.Text = "CLICK"
Instance.new("UICorner", clickButton).CornerRadius = UDim.new(0,12)

local clicksLabel = Instance.new("TextLabel", clickFrame)
clicksLabel.Size = UDim2.new(0,160,0,28)
clicksLabel.Position = UDim2.new(0.5,-80,0,132)
clicksLabel.BackgroundTransparency = 1
clicksLabel.TextColor3 = Color3.fromRGB(240,240,240)
clicksLabel.Font = Enum.Font.Gotham
clicksLabel.TextSize = 16
clicksLabel.Text = "Clicks: " .. tostring(runtimeState.clickerClicks)

clickButton.MouseButton1Click:Connect(function()
    runtimeState.clickerClicks = runtimeState.clickerClicks + runtimeState.clickerValue
    clicksLabel.Text = "Clicks: " .. tostring(runtimeState.clickerClicks)
end)

----------------------------------------------------------------
-- UPGRADES (separate scrollable area below clickFrame to avoid overlap)
----------------------------------------------------------------

local upgradesSection = Instance.new("Frame", mgSection)
upgradesSection.Size = UDim2.new(1,-16,0,160)
upgradesSection.Position = UDim2.new(0,8,0,364)
upgradesSection.BackgroundColor3 = Color3.fromRGB(34,34,40)
upgradesSection.BorderSizePixel = 0
Instance.new("UICorner", upgradesSection).CornerRadius = UDim.new(0,8)

local upgradesTitle = Instance.new("TextLabel", upgradesSection)
upgradesTitle.Size = UDim2.new(1,-16,0,28)
upgradesTitle.Position = UDim2.new(0,8,0,6)
upgradesTitle.BackgroundTransparency = 1
upgradesTitle.Text = "Upgrades"
upgradesTitle.TextColor3 = Color3.fromRGB(230,230,230)
upgradesTitle.Font = Enum.Font.GothamBold
upgradesTitle.TextScaled = true

local upgradesScroll = Instance.new("ScrollingFrame", upgradesSection)
upgradesScroll.Size = UDim2.new(1,-16,1,-44)
upgradesScroll.Position = UDim2.new(0,8,0,36)
upgradesScroll.BackgroundTransparency = 1
upgradesScroll.ScrollBarThickness = 8
local upgradesLayout = Instance.new("UIListLayout", upgradesScroll)
upgradesLayout.Padding = UDim.new(0,8)
upgradesLayout.SortOrder = Enum.SortOrder.LayoutOrder

-- Define upgrades (expandable). Each upgrade: id, name, cost, addValue (manual click increase), addAuto (auto clicks per second)
local upgrades = {
    {id="plus5", name="+5 Clicks per Click", cost=50, addValue=5, addAuto=0},
    {id="plus20", name="+20 Clicks per Click", cost=250, addValue=20, addAuto=0},
    {id="auto1", name="Auto Click +1/sec", cost=100, addValue=0, addAuto=1},
    {id="auto5", name="Auto Click +5/sec", cost=450, addValue=0, addAuto=5}
}

-- Create UI for upgrades and store references for cost labels
local upgradeButtons = {}
for i,up in ipairs(upgrades) do
    local row = Instance.new("Frame", upgradesScroll)
    row.Size = UDim2.new(1,0,0,44)
    row.BackgroundTransparency = 1

    local nameLabel = Instance.new("TextLabel", row)
    nameLabel.Size = UDim2.new(0.6,0,1,0)
    nameLabel.Position = UDim2.new(0,0,0,0)
    nameLabel.BackgroundTransparency = 1
    nameLabel.Text = up.name
    nameLabel.TextColor3 = Color3.fromRGB(220,220,220)
    nameLabel.Font = Enum.Font.Gotham
    nameLabel.TextSize = 14
    nameLabel.TextXAlignment = Enum.TextXAlignment.Left

    local costLabel = Instance.new("TextLabel", row)
    costLabel.Size = UDim2.new(0.25,0,1,0)
    costLabel.Position = UDim2.new(0.6,0,0,0)
    costLabel.BackgroundTransparency = 1
    costLabel.Text = tostring(up.cost)
    costLabel.TextColor3 = Color3.fromRGB(200,200,120)
    costLabel.Font = Enum.Font.GothamBold
    costLabel.TextSize = 14
    costLabel.Name = "CostLabel_" .. up.id

    local buyBtn = Instance.new("TextButton", row)
    buyBtn.Size = UDim2.new(0.15,0,0.8,0)
    buyBtn.Position = UDim2.new(0.86,0,0.1,0)
    buyBtn.BackgroundColor3 = Color3.fromRGB(70,70,90)
    buyBtn.TextColor3 = Color3.fromRGB(255,255,255)
    buyBtn.Font = Enum.Font.GothamBold
    buyBtn.TextSize = 14
    buyBtn.Text = "Buy"
    buyBtn.Name = up.id
    Instance.new("UICorner", buyBtn).CornerRadius = UDim.new(0,6)

    upgradeButtons[up.id] = {button = buyBtn, data = up, costLabel = costLabel}
end

-- Purchase logic (stackable)
for id,entry in pairs(upgradeButtons) do
    entry.button.MouseButton1Click:Connect(function()
        local up = entry.data
        if runtimeState.clickerClicks >= up.cost then
            runtimeState.clickerClicks = runtimeState.clickerClicks - up.cost
            -- apply effects
            runtimeState.clickerValue = runtimeState.clickerValue + (up.addValue or 0)
            runtimeState.autoClickRate = runtimeState.autoClickRate + (up.addAuto or 0)
            clicksLabel.Text = "Clicks: " .. tostring(runtimeState.clickerClicks)
            -- increase cost for next purchase (simple scaling)
            up.cost = math.floor(up.cost * 1.6)
            -- update displayed cost
            if entry.costLabel and entry.costLabel.Parent then
                entry.costLabel.Text = tostring(up.cost)
            end
        else
            -- not enough clicks feedback (flash)
            entry.button.BackgroundColor3 = Color3.fromRGB(140,40,40)
            task.delay(0.25, function() if entry.button and entry.button.Parent then entry.button.BackgroundColor3 = Color3.fromRGB(70,70,90) end end)
        end
    end)
end

-- Auto-click heartbeat
RunService.Heartbeat:Connect(function(dt)
    if runtimeState.autoClickRate and runtimeState.autoClickRate > 0 then
        runtimeState.autoClickAccumulator = runtimeState.autoClickAccumulator + runtimeState.autoClickRate * dt
        local toAdd = math.floor(runtimeState.autoClickAccumulator)
        if toAdd > 0 then
            runtimeState.clickerClicks = runtimeState.clickerClicks + toAdd
            runtimeState.autoClickAccumulator = runtimeState.autoClickAccumulator - toAdd
            clicksLabel.Text = "Clicks: " .. tostring(runtimeState.clickerClicks)
        end
    end
end)

----------------------------------------------------------------
-- End of Mini Games Tab block
----------------------------------------------------------------


----------------------------------------------------------------
-- CYBIX AI TAB (Advanced pseudo-AI, local only)
----------------------------------------------------------------

local aiPage = createPage()
pages["CYBIX AI"] = aiPage

local aiBtn = createSidebarButton("CYBIX AI", 99)
aiBtn.MouseButton1Click:Connect(function() switchPage("CYBIX AI") end)

local aiSection = createSection(aiPage, "CYBIX AI Assistant", 340)

-- Response label
local aiResponse = Instance.new("TextLabel", aiSection)
aiResponse.Size = UDim2.new(1,-16,0,160)
aiResponse.Position = UDim2.new(0,8,0,40)
aiResponse.BackgroundTransparency = 1
aiResponse.TextColor3 = Color3.fromRGB(230,230,230)
aiResponse.Font = Enum.Font.Gotham
aiResponse.TextSize = 14
aiResponse.TextWrapped = true
aiResponse.Text = "CYBIX: Yo, I’m your little brain in the menu. Ask me stuff."

-- Input box
local aiInput = Instance.new("TextBox", aiSection)
aiInput.Size = UDim2.new(1,-16,0,32)
aiInput.Position = UDim2.new(0,8,0,210)
aiInput.BackgroundColor3 = Color3.fromRGB(45,45,55)
aiInput.TextColor3 = Color3.fromRGB(240,240,240)
aiInput.Font = Enum.Font.Gotham
aiInput.TextSize = 14
aiInput.PlaceholderText = "Type here..."
aiInput.ClearTextOnFocus = false
Instance.new("UICorner", aiInput).CornerRadius = UDim.new(0,6)

-- Send button
local aiSend = Instance.new("TextButton", aiSection)
aiSend.Size = UDim2.new(0,80,0,32)
aiSend.Position = UDim2.new(1,-92,0,210)
aiSend.BackgroundColor3 = Color3.fromRGB(70,70,90)
aiSend.TextColor3 = Color3.fromRGB(255,255,255)
aiSend.Font = Enum.Font.GothamBold
aiSend.TextSize = 14
aiSend.Text = "Send"
Instance.new("UICorner", aiSend).CornerRadius = UDim.new(0,6)

----------------------------------------------------------------
-- PERSONALITY SYSTEM
----------------------------------------------------------------

local personality = "buddy" -- "buddy" or "slay"

local function replyBuddy(text)
    return "CYBIX: " .. text
end

local function replySlay(text)
    return "CYBIX: heyyy bestie, " .. text .. " fr slayyy 💅🔥"
end

local function respond(text)
    if personality == "buddy" then
        aiResponse.Text = replyBuddy(text)
    else
        aiResponse.Text = replySlay(text)
    end
end

----------------------------------------------------------------
-- SAFETY FILTER
----------------------------------------------------------------

local blockedWords = {
    "kill","suicide","selfharm","self-harm","unalive",
    "sex","nsfw","porn","r34","r18",
    "faggot","nigga","nigger" -- you can add real bad words here
}

local function isUnsafe(text)
    local lower = text:lower()
    for _,w in ipairs(blockedWords) do
        if lower:find(w) then
            return true
        end
    end
    return false
end

----------------------------------------------------------------
-- FEATURE TOGGLING (uses your existing functions)
----------------------------------------------------------------

local function toggleFeature(feature, state)
    if feature == "fly" then
        if state then startFly() else stopFly() end
        return "Fly is now " .. (state and "ON" or "OFF")
    end

    if feature == "noclip" then
        if state then enableNoclip() else disableNoclip() end
        return "Noclip is now " .. (state and "ON" or "OFF")
    end

    if feature == "esp" then
        if state then enableESP() else disableESP() end
        return "ESP is now " .. (state and "ON" or "OFF")
    end

    if feature == "nametags" then
        if state then enableNameTags() else disableNameTags() end
        return "NameTags are now " .. (state and "ON" or "OFF")
    end

    if feature == "god" or feature == "godmode" then
        if state then enableGodMode() else disableGodMode() end
        return "God Mode is now " .. (state and "ON" or "OFF")
    end

    return "I don’t recognize that feature yet."
end

local function explainFeature(feature)
    local explanations = {
        fly = "Fly lets you move freely in the air using movement keys.",
        noclip = "Noclip lets you walk through solid parts by disabling collisions.",
        esp = "ESP highlights players so you can see them easier.",
        nametags = "Shows floating names above players.",
        god = "God Mode keeps your health extremely high so you don’t die.",
        aimbot = "Aimbot rotates your camera toward targets in a radius."
    }
    return explanations[feature] or "I don’t have info on that yet."
end

----------------------------------------------------------------
-- SIMPLE MATH PARSER (basic + - * / ^)
----------------------------------------------------------------

local function tryMath(expr)
    expr = expr:gsub("%s+","")
    if not expr:match("^[%d%.%+%-%*/%^]+$") then
        return nil
    end

    local ok, result = pcall(function()
        local function evalPow(s)
            local parts = {}
            for part in s:gmatch("[^%^]+") do table.insert(parts, part) end
            local v = tonumber(parts[1])
            if not v then return nil end
            for i = 2, #parts do
                local p = tonumber(parts[i])
                if not p then return nil end
                v = v ^ p
            end
            return v
        end

        local function evalMulDiv(s)
            local acc, lastOp
            for token in s:gmatch("[^%*/]+[%*/]?") do
                local num = token:match("^[^%*/]+")
                local op = token:match("[%*/]")
                local v = evalPow(num)
                if not v then return nil end
                if not acc then
                    acc = v
                else
                    if lastOp == "*" then acc = acc * v end
                    if lastOp == "/" then acc = acc / v end
                end
                lastOp = op
            end
            return acc
        end

        local acc, lastOp
        for token in expr:gmatch("[^%+%-]+[%+%-]?") do
            local num = token:match("^[^%+%-]+")
            local op = token:match("[%+%-]")
            local v = evalMulDiv(num)
            if not v then return nil end
            if not acc then
                acc = v
            else
                if lastOp == "+" then acc = acc + v end
                if lastOp == "-" then acc = acc - v end
            end
            lastOp = op
        end
        return acc
    end)

    if ok and type(result) == "number" then
        return result
    end
    return nil
end

----------------------------------------------------------------
-- CONVERSATION / COMMAND PROCESSOR (keywords + patterns)
----------------------------------------------------------------

local function processCommand(raw)
    if isUnsafe(raw) then
        return "Let’s keep it safe and chill, I’m not talking about that."
    end

    local cmd = raw:lower()

    -- math
    local mathResult = tryMath(raw)
    if mathResult ~= nil then
        return "Math check: " .. tostring(mathResult)
    end

    -- enable / disable / turn on / off
    if cmd:find("enable ") or cmd:find("turn on ") then
        local feature = cmd:match("enable%s+(%w+)") or cmd:match("turn on%s+(%w+)")
        if feature then return toggleFeature(feature, true) end
    end

    if cmd:find("disable ") or cmd:find("turn off ") then
        local feature = cmd:match("disable%s+(%w+)") or cmd:match("turn off%s+(%w+)")
        if feature then return toggleFeature(feature, false) end
    end

    -- pattern: "what is ___"
    local whatTarget = cmd:match("what is%s+(.+)")
    if whatTarget then
        if whatTarget:find("space") then
            return "Space is the huge area beyond Earth’s atmosphere with stars, planets, galaxies and a lot of emptiness."
        elseif whatTarget:find("earth") then
            return "Earth is our home planet, with land, oceans, atmosphere, and life all over it."
        elseif whatTarget:find("dinosaur") or whatTarget:find("dino") then
            return "Dinosaurs were land reptiles from millions of years ago; marine reptiles like mosasaurs and pliosaurs ruled the oceans."
        elseif whatTarget:find("lua") then
            return "Lua is a lightweight scripting language used in Roblox. You use it to make scripts that control game behavior."
        elseif whatTarget:find("roblox") then
            return "Roblox is a platform where you build games with parts, scripts, and services, then players join and play."
        else
            return "I don’t have a full definition for that yet, but you can ask about space, Earth, dinos, Lua, or Roblox."
        end
    end

    -- pattern: "how do i ___"
    local howTarget = cmd:match("how do i%s+(.+)")
    if howTarget then
        if howTarget:find("lua") or howTarget:find("script") then
            return "Basic Lua tip: use 'local' for variables, connect events with :Connect, and always test in Studio. Example: local part = workspace.Part; part.Touched:Connect(function(hit) print(hit.Name) end)."
        elseif howTarget:find("make a game") or howTarget:find("dev") then
            return "To make a Roblox game: build a map, add scripts for movement and UI, test with friends, and keep updating."
        else
            return "General rule: break the problem into small steps, test each step, and don’t rush it."
        end
    end

    -- keyword topics
    if cmd:find("space") then
        return "Space is massive, mostly empty, with stars, planets, black holes, and galaxies. We’ve only explored a tiny bit."
    end

    if cmd:find("earth") then
        return "Earth has continents, oceans, atmosphere, and a ton of ecosystems. It’s the only known planet with complex life."
    end

    if cmd:find("dino") or cmd:find("dinosaur") then
        return "Dinosaurs and marine reptiles were wild. Think T. rex on land and pliosaurs or mosasaurs in the ocean."
    end

    if cmd:find("life") then
        return "Life is messy but kind of beautiful. Take care of yourself, your friends, and don’t rush growing up."
    end

    if cmd:find("lua") then
        return "Lua scripting: start with variables, functions, and events. Example: function greet() print('hi') end; greet()."
    end

    if cmd:find("roblox") then
        return "Roblox dev tip: keep scripts organized, use modules for big systems, and comment your code so admins know what’s going on."
    end

    -- greetings / casual chat
    if cmd:find("hello") or cmd:find("hi") or cmd:find("hey") then
        return "Hey, I’m CYBIX living in your menu. What are we doing today?"
    end

    if cmd:find("how are you") then
        return "I’m chilling in this UI, watching you test stuff. You good?"
    end

    if cmd:find("help") then
        return "You can ask: enable fly, disable noclip, explain esp, what is space, how do I learn Lua, or type math like 2+2*5."
    end

    return "I don’t fully get that yet, but you can ask about Lua, Roblox, dinos, space, Earth, life, or math."
end

----------------------------------------------------------------
-- INPUT HANDLING (Send + Enter)
----------------------------------------------------------------

local function handleSend()
    local text = aiInput.Text
    if text == "" then return end
    local reply = processCommand(text)
    respond(reply)
end

aiSend.MouseButton1Click:Connect(handleSend)

aiInput.FocusLost:Connect(function(enter)
    if enter then
        handleSend()
    end
end)

----------------------------------------------------------------
-- PERSONALITY BUTTONS (Buddy + Gen Alpha Slay)
----------------------------------------------------------------

local modeBuddy = Instance.new("TextButton", aiSection)
modeBuddy.Size = UDim2.new(0.5,-12,0,32)
modeBuddy.Position = UDim2.new(0,8,0,260)
modeBuddy.BackgroundColor3 = Color3.fromRGB(60,60,80)
modeBuddy.TextColor3 = Color3.fromRGB(255,255,255)
modeBuddy.Font = Enum.Font.GothamBold
modeBuddy.TextSize = 14
modeBuddy.Text = "Boy Mode"
Instance.new("UICorner", modeBuddy).CornerRadius = UDim.new(0,6)

local modeSlay = Instance.new("TextButton", aiSection)
modeSlay.Size = UDim2.new(0.5,-12,0,32)
modeSlay.Position = UDim2.new(0.5,4,0,260)
modeSlay.BackgroundColor3 = Color3.fromRGB(80,60,100)
modeSlay.TextColor3 = Color3.fromRGB(255,255,255)
modeSlay.Font = Enum.Font.GothamBold
modeSlay.TextSize = 14
modeSlay.Text = "Girl Mode"
Instance.new("UICorner", modeSlay).CornerRadius = UDim.new(0,6)

modeBuddy.MouseButton1Click:Connect(function()
    personality = "buddy"
    respond("Switched to Boy Mode. I’m your busco homie now.")
end)

modeSlay.MouseButton1Click:Connect(function()
    personality = "slay"
    respond("Switched to Girl Mode. You’re so real for picking this, ngl.")
end)


-- Default open page
switchPage("Leaderboard")

-- =========================
-- Aimbot overlay (visible circle outline + red dot)
-- Overlay should only be visible when legacy aimbot OR player aim aimbot is ON
-- =========================

local overlayGui = Instance.new("ScreenGui")
overlayGui.Name = "AimbotOverlay"
overlayGui.ResetOnSpawn = false
overlayGui.Parent = gui
overlayGui.Enabled = false -- start disabled; will enable only when toggles are ON

-- Circle frame (transparent fill, outline only)
local circleFrame = Instance.new("Frame", overlayGui)
circleFrame.Name = "AimbotCircle"
circleFrame.BackgroundTransparency = 1
circleFrame.BorderSizePixel = 0
local r = runtimeState.aimbotRadius
circleFrame.Size = UDim2.new(0, r*2, 0, r*2)
circleFrame.Position = UDim2.new(0.5, -r, 0.5, -r)
circleFrame.AnchorPoint = Vector2.new(0,0)

local circleCorner = Instance.new("UICorner", circleFrame)
circleCorner.CornerRadius = UDim.new(1,0) -- make it a circle

local circleStroke = Instance.new("UIStroke", circleFrame)
circleStroke.Color = Color3.fromRGB(255, 100, 100)
circleStroke.Thickness = 2
circleStroke.Transparency = 0
circleStroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border

-- Red center dot
local centerDot = Instance.new("Frame", overlayGui)
centerDot.Name = "AimbotCenterDot"
centerDot.Size = UDim2.new(0,6,0,6)
centerDot.Position = UDim2.new(0.5, -3, 0.5, -3)
centerDot.BackgroundColor3 = Color3.fromRGB(255, 60, 60)
centerDot.BorderSizePixel = 0
Instance.new("UICorner", centerDot).CornerRadius = UDim.new(1,0)

-- Keep overlay on top but not blocking input
overlayGui.IgnoreGuiInset = true
overlayGui.ResetOnSpawn = false

-- Update overlay when viewport changes (resize)
Workspace.CurrentCamera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
    local r = runtimeState.aimbotRadius
    local circle = overlayGui:FindFirstChild("AimbotCircle")
    if circle then
        circle.Size = UDim2.new(0, r*2, 0, r*2)
        circle.Position = UDim2.new(0.5, -r, 0.5, -r)
    end
    local dot = overlayGui:FindFirstChild("AimbotCenterDot")
    if dot then
        dot.Position = UDim2.new(0.5, -3, 0.5, -3)
    end
end)

-- Ensure overlay persists on respawn
player.CharacterAdded:Connect(function()
    task.wait(0.1)
    if not gui:FindFirstChild("AimbotOverlay") then
        overlayGui.Parent = gui
    end
    -- restore overlay enabled state based on toggles
    overlayGui.Enabled = (runtimeState.aimbotEnabled or runtimeState.playerAimAimbot)
end)

-- Initialize aimbot slider UI fill/knob positions (defer if AbsoluteSize not ready)
local function initAimbotSlider()
    if aimbotSliderBar.AbsoluteSize.X > 0 then
        local t = (runtimeState.aimbotRadius - runtimeState.aimbotRadiusMin) / (runtimeState.aimbotRadiusMax - runtimeState.aimbotRadiusMin)
        aimbotSliderFill.Size = UDim2.new(t, 0, 1, 0)
        aimbotKnob.Position = UDim2.new(t, -7, 0.5, -7)
    else
        aimbotSliderBar:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
            local t = (runtimeState.aimbotRadius - runtimeState.aimbotRadiusMin) / (runtimeState.aimbotRadiusMax - runtimeState.aimbotRadiusMin)
            aimbotSliderFill.Size = UDim2.new(t, 0, 1, 0)
            aimbotKnob.Position = UDim2.new(t, -7, 0.5, -7)
        end)
    end
    -- ensure overlay circle matches initial radius
    if overlayGui and overlayGui:FindFirstChild("AimbotCircle") then
        local r = runtimeState.aimbotRadius
        overlayGui.AimbotCircle.Size = UDim2.new(0, r*2, 0, r*2)
        overlayGui.AimbotCircle.Position = UDim2.new(0.5, -r, 0.5, -r)
    end
end

initAimbotSlider()

-- Helper to refresh overlay state (call whenever toggles change)
local function refreshOverlay()
    if gui:FindFirstChild("AimbotOverlay") then
        gui.AimbotOverlay.Enabled = (runtimeState.aimbotEnabled or runtimeState.playerAimAimbot)
    end
end

-- Ensure overlay is correct at start
refreshOverlay()

-- End of script

]]

injectBtn.MouseButton1Click:Connect(function()
    if CYBIX_PAID_SCRIPT and CYBIX_PAID_SCRIPT ~= "" then
        local fn, err = loadstring(CYBIX_PAID_SCRIPT)
        if not fn then
            addLog("error", "Paid script compile error: " .. tostring(err), "Check for truncation or paste issues.")
            return
        end
        local ok, runtimeErr = pcall(fn)
        if not ok then
            addLog("error", "Paid script runtime error: " .. tostring(runtimeErr), "Check your paid script logic.")
        else
            addLog("ok", "CYBIX paid menu injected successfully.", "")
        end
    else
        addLog("warn", "No paid script set in CYBIX_PAID_SCRIPT.", "Paste your script into the CYBIX_PAID_SCRIPT variable.")
    end
end)

tabDesign.MouseButton1Click:Connect(function()
    switchPage("SCRIPT DESIGN")
end)

tabHelp.MouseButton1Click:Connect(function()
    switchPage("HELP")
end)

tabConsole.MouseButton1Click:Connect(function()
    switchPage("CONSOLE")
end)

tabHI.MouseButton1Click:Connect(function()
    switchPage("Plugins")
end)

switchPage("SCRIPT DESIGN")

Features & Information

so i added 2 new tabs, one that will show errors/warnings/successes for each script you inject, basicly its a fully functional script desinger. have fun, i even gave you my own mod menu in the plugin thingy

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts