CCCPaste
-- Volleyball Legends — Studio-safe refactor with Hitbox Visualizer
-- WARNING: SAFE FOR DEVELOPMENT / STUDIO USE ONLY. NO bypass/loadstring, NO firetouchinterest.
-- Place in StarterPlayer > StarterPlayerScripts

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

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")

-- Venyx UI (local copy). Replace this load if you prefer a different UI.
local library = loadstring(game:HttpGet("https://raw.githubusercontent.com/zxciaz/VenyxUI/main/Reupload"))()
local venyx  = library.new("Volleyball Legends v3.0 (Studio)", 5013109572)

local themes = {
    Background    = Color3.fromRGB(24,24,24),
    Glow          = Color3.fromRGB(0,255,255),
    Accent        = Color3.fromRGB(10,10,10),
    LightContrast = Color3.fromRGB(20,20,20),
    DarkContrast  = Color3.fromRGB(14,14,14),
    TextColor     = Color3.fromRGB(255,255,255),
}

local page = venyx:addPage("Main", 5012544693)
local section1 = page:addSection("AutoBump Settings")
local section2 = page:addSection("Player Settings")
local sectionHitbox = page:addSection("Hitbox Visualizer")
local section3 = page:addSection("Credits")

-- Settings
local settings = {
    AutoBump        = false,  -- KEEP OFF by default (non-exploit)
    AutoPosition    = false,
    AntiAFK         = false,
    BumpRange       = 15,
    JumpWhileBump   = true,
    DebugMode       = false,

    -- Hitbox visualizer
    HitboxEnabled   = false,
    HitboxRadius    = 3,     -- studs
    HitboxShowFill  = false,
    HitboxColor     = Color3.fromRGB(0,255,128),
    HitboxAlpha     = 0.45,
}

-- UI elements
section1:addToggle("AutoBump (placeholder)", settings.AutoBump, function(v) settings.AutoBump = v end)
section1:addToggle("Jump While Bump", settings.JumpWhileBump, function(v) settings.JumpWhileBump = v end)
section1:addSlider("Bump Range", settings.BumpRange, 5, 30, function(v) settings.BumpRange = v end)

section2:addToggle("Auto Position (client-only)", settings.AutoPosition, function(v) settings.AutoPosition = v end)
section2:addToggle("Anti-AFK (client-only)", settings.AntiAFK, function(v) settings.AntiAFK = v end)
section2:addToggle("Debug Mode", settings.DebugMode, function(v) settings.DebugMode = v end)

-- Hitbox UI
sectionHitbox:addToggle("Enable Hitbox Visualizer", settings.HitboxEnabled, function(v) settings.HitboxEnabled = v end)
sectionHitbox:addSlider("Hitbox Radius", settings.HitboxRadius, 0.2, 20, function(v) settings.HitboxRadius = v end)
sectionHitbox:addToggle("Show Fill", settings.HitboxShowFill, function(v) settings.HitboxShowFill = v end)
-- optional color / alpha could be added if Venyx supports color pickers

section3:addButton("Script by AdamDaOne (refactor)", function() setclipboard("AdamDaOne on GitHub") end)
section3:addKeybind("Toggle GUI", Enum.KeyCode.RightControl, function() venyx:toggle() end, function() end)

venyx:setTheme(themes)
venyx:selectPage(venyx.pages[1], true)

-- =========================
-- Ball finder utilities
-- =========================
local ballNameCandidates = {"Ball","Volleyball","ball"}
local function findBall()
    for _, name in ipairs(ballNameCandidates) do
        local b = Workspace:FindFirstChild(name)
        if b and b:IsA("BasePart") then return b end
    end
    -- fallback: fuzzy search
    for _, v in ipairs(Workspace:GetDescendants()) do
        if v:IsA("BasePart") and (v.Name:lower():find("ball") or v.Name:lower():find("volley")) then
            return v
        end
    end
    return nil
end

-- =========================
-- Hitbox Visualizer (client-only)
-- =========================
local visual = nil
local ring = nil
local function createVisualizer()
    if visual and visual.Parent then return end

    visual = Instance.new("Part")
    visual.Name = "HitboxVisualizer_Part"
    visual.Anchored = true
    visual.CanCollide = false
    visual.CastShadow = false
    visual.Transparency = 1
    visual.Material = Enum.Material.Neon
    visual.Parent = workspace

    local mesh = Instance.new("SpecialMesh", visual)
    mesh.MeshType = Enum.MeshType.Sphere
    mesh.Name = "SphereMesh"

    ring = Instance.new("Part")
    ring.Name = "HitboxVisualizer_Ring"
    ring.Anchored = true
    ring.CanCollide = false
    ring.CastShadow = false
    ring.Transparency = 1
    ring.Material = Enum.Material.Neon
    ring.Parent = workspace

    local ringMesh = Instance.new("SpecialMesh", ring)
    ringMesh.MeshType = Enum.MeshType.Sphere
    ringMesh.Name = "RingMesh"

    visual:SetAttribute("viz", true)
    ring:SetAttribute("viz", true)
end

local function destroyVisualizer()
    if visual then pcall(function() visual:Destroy() end) end
    if ring then pcall(function() ring:Destroy() end) end
    visual = nil; ring = nil
end

local function applyVisualSize(radius)
    if not visual or not ring then return end
    local diameter = math.max(0.05, radius * 2)
    local mesh = visual:FindFirstChild("SphereMesh")
    local ringMesh = ring:FindFirstChild("RingMesh")
    if mesh then mesh.Scale = Vector3.new(diameter, diameter, diameter) end
    if ringMesh then ringMesh.Scale = Vector3.new(diameter * 1.01, 0.06, diameter * 1.01) end

    -- color/transparency
    visual.Color = settings.HitboxColor
    if settings.HitboxShowFill then
        visual.Transparency = math.clamp(1 - (settings.HitboxAlpha), 0, 1)
    else
        visual.Transparency = 1 -- invisible fill when not showing fill
    end

    ring.Color = settings.HitboxColor
    ring.Transparency = math.clamp(1 - 0.92, 0, 1) -- thin visible ring tint
end

local function updateVisualizer(ballPart)
    if not settings.HitboxEnabled then
        destroyVisualizer()
        return
    end
    if not ballPart or not ballPart:IsDescendantOf(workspace) then
        destroyVisualizer()
        return
    end

    createVisualizer()
    local pos = ballPart.Position
    visual.CFrame = CFrame.new(pos)
    ring.CFrame = CFrame.new(pos) * CFrame.Angles(math.rad(90),0,0)
    applyVisualSize(settings.HitboxRadius)
end

-- =========================
-- AutoBump (placeholder) - NO simulated touches
-- =========================
local function bumpBall()
    if not settings.AutoBump then return end
    local ball = findBall()
    if not ball then return end
    local distance = (ball.Position - rootPart.Position).Magnitude
    if distance <= settings.BumpRange then
        if settings.JumpWhileBump and character and character:FindFirstChild("Humanoid") then
            character.Humanoid.Jump = true
        end
        -- SAFE: do NOT call firetouchinterest. Instead:
        -- 1) print/log for testing, OR
        -- 2) trigger a server RemoteEvent that YOU implement server-side (recommended secure approach).
        if settings.DebugMode then
            print("[AutoBump] In-range, would attempt bump. Distance:", distance)
        end
        -- Example: if you created a RemoteEvent named "RequestBump" under ReplicatedStorage,
        -- you could call it here to request a server-authoritative bump. Not included by default.
    end
end

-- =========================
-- Auto-positioning
-- =========================
local function positionPlayer()
    if not settings.AutoPosition then return end
    local ball = findBall()
    if not ball then return end
    local targetPosition = ball.Position + Vector3.new(0, 3, 0)
    rootPart.CFrame = CFrame.new(targetPosition) * CFrame.new(math.random(-2,2), 0, math.random(-2,2))
end

-- =========================
-- Anti-AFK (benign emulation)
-- =========================
local lastMovement = tick()
if settings.AntiAFK then
    coroutine.wrap(function()
        while true do
            wait(30)
            if settings.AntiAFK then
                -- benign short key pulse to simulate activity in Studio only
                UIS:SetCore("SendNotification", {Title="AntiAFK", Text="Client-side ping", Duration=1})
                lastMovement = tick()
            end
            wait(1)
        end
    end)()
end

-- =========================
-- Main loop
-- =========================
local targetBall = findBall()
Workspace.DescendantAdded:Connect(function(desc)
    if not targetBall and desc:IsA("BasePart") and desc.Name:lower():find("ball") then
        targetBall = desc
    end
end)

RunService.Heartbeat:Connect(function(dt)
    pcall(function()
        if not character or not character.Parent then
            character = player.Character
            if character then rootPart = character:WaitForChild("HumanoidRootPart") end
            return
        end

        positionPlayer()
        bumpBall()

        -- anti-afk pulse fallback
        if settings.AntiAFK and (tick() - lastMovement) > 20 then
            UIS:SetCore("SendNotification", {Title="AntiAFK", Text="Auto pulse", Duration=1})
            lastMovement = tick()
        end

        -- update hitbox visualizer
        if settings.HitboxEnabled and (targetBall and targetBall:IsDescendantOf(workspace)) then
            updateVisualizer(targetBall)
        else
            destroyVisualizer()
            -- try to reacquire ball
            if not targetBall or not targetBall:IsDescendantOf(workspace) then
                targetBall = findBall()
            end
        end
    end)
end)

-- Notification (Studio-friendly)
if startergui and startergui.SetCore then
    pcall(function()
        game.StarterGui:SetCore("SendNotification", {
            Title = "Volleyball Legends (Studio)",
            Text  = "Script loaded (studio-safe). Use GUI to enable Visualizer.",
            Duration = 6
        })
    end)
end

print("Volleyball Legends (Studio-safe) Loaded | Hitbox Visualizer integrated")