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

local Window = Rayfield:CreateWindow({
    Name = "Scorpio Hub",
    LoadingTitle = "Scorpio Hub Loading",
    LoadingSubtitle = "by @FoxyYT098",
    ConfigurationSaving = {
       Enabled = true,
       FolderName = Soupy Hub Folder1, -- Create a custom folder for your hub/game
       FileName = "sui haun hub"
    },
    Discord = {
       Enabled = true,
       Invite = "Ez5xfGh2cs", -- The Discord invite code, do not include discord.gg/. E.g. discord.gg/ABCD would be ABCD
       RememberJoins = true -- Set this to false to make them join the discord every time they load it up
    },
    KeySystem = false, -- Set this to true to use our key system
    KeySettings = {
       Title = "Soupy Hub Key",
       Subtitle = "Paste the key here ⬇",
       Note = "Go to https://[Log in to view URL] ",
       FileName = "Key11232323", -- It is recommended to use something unique as other scripts using Rayfield may overwrite your key file
       SaveKey = true, -- The user's key will be saved, but if you change the key, they will be unable to use your script
       GrabKeyFromSite = true, -- If this is true, set Key below to the RAW site you would like Rayfield to get the key from
       Key = {"FoxyYTtm123","https://[Log in to view URL]"} -- List of keys that will be accepted by the system, can be RAW file links (pastebin, github etc) or simple strings ("hello","key22")
    }
 })

local MainTab = Window:CreateTab("Main Thingys", nil) -- Title, Image
local MainSection = MainTab:CreateSection("Player")

local basketballs = {
    workspace.Courts["1v1 Court_1"].Basketball,
    workspace.Courts["1v1 Court_2"].Basketball,
    workspace.Courts["3v3"].Basketball,
    workspace.Courts["2v2 Court_1"].Basketball,
    workspace.Courts["1v1 Court_4"].Basketball,
    workspace.Courts["1v1 Court_3"].Basketball,
    workspace.Courts["2v2 Court_2"].Basketball,
}

local autoTeleportEnabled = false
local teleportLoop = nil

MainTab:CreateToggle({
    Name = "Auto Teleport To Ball (May Not Work)",
    CurrentValue = false,
    Flag = "AutoTeleportToggle",
    Callback = function(Value)
        autoTeleportEnabled = Value

        if autoTeleportEnabled then
            teleportLoop = task.spawn(function()
                while autoTeleportEnabled do
                    if hrp then
                        for _, ball in ipairs(basketballs) do
                            if ball and ball:IsA("BasePart") then
                                local ballOwner = ball:FindFirstChild("Weld") or ball:FindFirstChildWhichIsA("WeldConstraint")
                                if not ballOwner then
                                    hrp.CFrame = CFrame.new(ball.Position + Vector3.new(0, 3, 0))
                                    hrp.Velocity = Vector3.zero
                                    break -- teleport to first free ball found
                                end
                            end
                        end
                    end
                    task.wait(0.2)
                end
            end)
        else
            teleportLoop = nil
        end
    end,
})

local g = getgenv()

g.spinbot = false
g.spinspeed = 10
g.infinitestamina = false
g.autosprint = false

-- SPIN BOT
MainTab:CreateToggle({
    Name = "Spin Bot",
    CurrentValue = false,
    Flag = "spinbot",
    Callback = function(state)
        g.spinbot = state

        local player = game.Players.LocalPlayer
        local char = player.Character

        if char and char:FindFirstChild("HumanoidRootPart") then
            local hrp = char.HumanoidRootPart
            local bv = hrp:FindFirstChild("sbn")

            if state then
                if not bv then
                    bv = Instance.new("BodyAngularVelocity")
                    bv.Name = "sbn"
                    bv.MaxTorque = Vector3.new(0, math.huge, 0)
                    bv.Parent = hrp
                end

                bv.AngularVelocity = Vector3.new(0, g.spinspeed, 0)
            else
                if bv then
                    bv:Destroy()
                end
            end
        end
    end
})

-- SPIN SPEED
MainTab:CreateSlider({
    Name = "Spin Speed",
    Range = {1, 50},
    Increment = 1,
    Suffix = "",
    CurrentValue = 10,
    Flag = "spinspeed",
    Callback = function(value)
        g.spinspeed = value

        local player = game.Players.LocalPlayer
        local char = player.Character

        if char and char:FindFirstChild("HumanoidRootPart") then
            local bv = char.HumanoidRootPart:FindFirstChild("sbn")

            if bv then
                bv.AngularVelocity = Vector3.new(0, value, 0)
            end
        end
    end
})

-- INFINITE STAMINA
MainTab:CreateToggle({
    Name = "Infinite Stamina",
    CurrentValue = false,
    Flag = "infstamina",
    Callback = function(state)
        g.infinitestamina = state

        task.spawn(function()
            while g.infinitestamina do
                task.wait(0.1)

                local player = game.Players.LocalPlayer

                if player:FindFirstChild("Values") then
                    local stamina = player.Values:FindFirstChild("Stamina")
                    local maxStamina = player.Values:FindFirstChild("MaxStamina")

                    if stamina and maxStamina then
                        stamina.Value = maxStamina.Value
                    end
                end
            end
        end)
    end
})

-- AUTO SPRINT
MainTab:CreateToggle({
    Name = "Auto Sprint",
    CurrentValue = false,
    Flag = "autosprint",
    Callback = function(state)
        g.autosprint = state

        task.spawn(function()
            while g.autosprint do
                task.wait(0.1)

                local player = game.Players.LocalPlayer
                local char = player.Character

                if char and char:FindFirstChildOfClass("Humanoid") then
                    local humanoid = char:FindFirstChildOfClass("Humanoid")

                    if humanoid.MoveDirection.Magnitude > 0 then
                        game:GetService("ReplicatedStorage")
                            .Events.Sprint:FireServer(
                                humanoid.MoveDirection.Magnitude
                            )
                    end
                end
            end
        end)
    end
})

-- VARIABLES
g.cframespeed = false
g.cfv = 5
g.antioob = false
g.antioob_new = false
g.anticontest = false
g.contestheight = 15.1
g.autoguard = false
g.dribbleglide = false
g.glidedistance = 5

g.clonethooobprt = {}
g.oobOriginalSizes = {}

local cfspeed_thread
local dribble_thread
local autoguard_thread

-- SECTIONS
MainTab:CreateSection("CFrame Speed")
MainTab:CreateSection("Anti")
MainTab:CreateSection("Auto")
MainTab:CreateSection("Dribble")

-- CFRAME SPEED TOGGLE
MainTab:CreateToggle({
    Name = "Walk Speed",
    CurrentValue = false,
    Flag = "cframespeed",
    Callback = function(state)
        g.cframespeed = state

        if state then
            cfspeed_thread = task.spawn(function()
                while g.cframespeed and task.wait() do
                    local char = game.Players.LocalPlayer.Character
                    local humanoid = char and char:FindFirstChildOfClass("Humanoid")
                    local hrp = char and char:FindFirstChild("HumanoidRootPart")

                    if humanoid and hrp and humanoid.MoveDirection.Magnitude > 0 then
                        local newPos =
                            hrp.Position +
                            (humanoid.MoveDirection * g.cfv * 0.1)

                        hrp.CFrame = hrp.CFrame:Lerp(
                            CFrame.new(
                                newPos,
                                newPos + humanoid.MoveDirection
                            ),
                            0.5
                        )
                    end
                end
            end)
        else
            if cfspeed_thread then
                task.cancel(cfspeed_thread)
            end
        end
    end
})

-- CFRAME SPEED SLIDER
MainTab:CreateSlider({
    Name = "Walk Speed Amount",
    Range = {1, 50},
    Increment = 1,
    Suffix = "",
    CurrentValue = 5,
    Flag = "cfspeedslider",
    Callback = function(value)
        g.cfv = value
    end
})

-- NO BOUNDARIES
MainTab:CreateToggle({
    Name = "No Boundaries",
    CurrentValue = false,
    Flag = "antioob",
    Callback = function(state)
        g.antioob = state

        local courts = workspace:FindFirstChild("Courts")

        if not courts then
            return
        end

        if state then
            for _, court in ipairs(courts:GetChildren()) do
                for _, part in ipairs(court:GetDescendants()) do
                    if part:IsA("BasePart") and
                        (part.Name:lower():find("oob")
                        or part.Name:lower():find("border")) then

                        g.clonethooobprt[part] = part:Clone()
                        part:Destroy()
                    end
                end
            end
        else
            for originalPart, clonedPart in pairs(g.clonethooobprt) do
                if originalPart and originalPart.Parent then
                    local newPart = clonedPart:Clone()
                    newPart.Parent = originalPart.Parent
                end
            end

            g.clonethooobprt = {}
        end
    end
})

-- ANTI OOB
MainTab:CreateToggle({
    Name = "Anti OOB",
    CurrentValue = false,
    Flag = "antioobnew",
    Callback = function(state)
        g.antioob_new = state

        if state then
            for _, part in ipairs(workspace:GetDescendants()) do
                if part:IsA("BasePart")
                    and part.Name == "OutOfBounds_1" then

                    g.oobOriginalSizes[part] = part.Size
                    part.Size = Vector3.new(0.0001, 0.0001, 0.001)
                end
            end
        else
            for part, originalSize in pairs(g.oobOriginalSizes) do
                if part and part.Parent then
                    part.Size = originalSize
                end
            end

            g.oobOriginalSizes = {}
        end
    end
})

-- ANTI CONTEST
MainTab:CreateToggle({
    Name = "Anti Contest",
    CurrentValue = false,
    Flag = "anticontest",
    Callback = function(state)
        g.anticontest = state
    end
})

-- CONTEST HEIGHT
MainTab:CreateSlider({
    Name = "Contest Height",
    Range = {0, 22},
    Increment = 1,
    Suffix = "",
    CurrentValue = 15,
    Flag = "contestheight",
    Callback = function(value)
        g.contestheight = value
    end
})

-- AUTO GUARD
MainTab:CreateToggle({
    Name = "Auto Guard",
    CurrentValue = false,
    Flag = "autoguard",
    Callback = function(state)
        g.autoguard = state

        if state then
            autoguard_thread = task.spawn(function()
                while g.autoguard and task.wait() do
                    local char = game.Players.LocalPlayer.Character
                    local humanoid =
                        char and char:FindFirstChildOfClass("Humanoid")

                    if humanoid and humanoid.RootPart then
                        humanoid:MoveTo(humanoid.RootPart.Position)

                        game:GetService("ReplicatedStorage")
                            .Events.Guard:FireServer()
                    end
                end
            end)
        else
            if autoguard_thread then
                task.cancel(autoguard_thread)
            end
        end
    end
})

-- DRIBBLE GLIDE
MainTab:CreateToggle({
    Name = "Dribble Glide",
    CurrentValue = false,
    Flag = "dribbleglide",
    Callback = function(state)
        g.dribbleglide = state

        if state then
            dribble_thread = task.spawn(function()
                while g.dribbleglide and task.wait() do
                    local player = game.Players.LocalPlayer
                    local char = player.Character
                    local values = player:FindFirstChild("Values")

                    if char and values
                        and values:FindFirstChild("Dribbling") then

                        if values.Dribbling.Value == true then
                            local humanoid =
                                char:FindFirstChildOfClass("Humanoid")

                            local hrp =
                                char:FindFirstChild("HumanoidRootPart")

                            if humanoid and hrp
                                and humanoid.MoveDirection.Magnitude > 0 then

                                local dist = g.glidedistance * 0.1

                                local newPos =
                                    hrp.Position +
                                    (humanoid.MoveDirection * dist)

                                hrp.CFrame = hrp.CFrame:Lerp(
                                    CFrame.new(
                                        newPos,
                                        newPos + humanoid.MoveDirection
                                    ),
                                    0.3
                                )
                            end
                        end
                    end
                end
            end)
        else
            if dribble_thread then
                task.cancel(dribble_thread)
            end
        end
    end
})

-- GLIDE DISTANCE
MainTab:CreateSlider({
    Name = "Glide Distance",
    Range = {0, 35},
    Increment = 1,
    Suffix = "",
    CurrentValue = 5,
    Flag = "glidedistance",
    Callback = function(value)
        g.glidedistance = value
    end
})

local SkyTab = Window:CreateTab("Player", 4483362458)

local Lighting = game:GetService("Lighting")
local RunService = game:GetService("RunService")

SkyTab:CreateSection("")

local skyPresets = {
    Traphouse = {
        SkyboxBk = "rbxassetid://77422488155748",
        SkyboxDn = "rbxassetid://77422488155748",
        SkyboxFt = "rbxassetid://77422488155748",
        SkyboxLf = "rbxassetid://77422488155748",
        SkyboxRt = "rbxassetid://77422488155748",
        SkyboxUp = "rbxassetid://77422488155748"
    },

    ScorpioHub = {
        SkyboxBk = "rbxassetid://77422488155748",
        SkyboxDn = "rbxassetid://77422488155748",
        SkyboxFt = "rbxassetid://77422488155748",
        SkyboxLf = "rbxassetid://77422488155748",
        SkyboxRt = "rbxassetid://77422488155748",
        SkyboxUp = "rbxassetid://77422488155748"
    },

    ARBY = {
        SkyboxBk = "rbxassetid://77422488155748",
        SkyboxDn = "rbxassetid://77422488155748",
        SkyboxFt = "rbxassetid://77422488155748",
        SkyboxLf = "rbxassetid://77422488155748",
        SkyboxRt = "rbxassetid://77422488155748",
        SkyboxUp = "rbxassetid://77422488155748"
    },

    COMP = {
        SkyboxBk = "rbxassetid://77422488155748",
        SkyboxDn = "rbxassetid://77422488155748",
        SkyboxFt = "rbxassetid://77422488155748",
        SkyboxLf = "rbxassetid://77422488155748",
        SkyboxRt = "rbxassetid://77422488155748",
        SkyboxUp = "rbxassetid://77422488155748"
    },

    LuffyGear5 = {
        SkyboxBk = "rbxassetid://77422488155748",
        SkyboxDn = "rbxassetid://77422488155748",
        SkyboxFt = "rbxassetid://77422488155748",
        SkyboxLf = "rbxassetid://77422488155748",
        SkyboxRt = "rbxassetid://77422488155748",
        SkyboxUp = "rbxassetid://77422488155748"
    },

    SkeletonMeme = {
        SkyboxBk = "rbxassetid://77422488155748",
        SkyboxDn = "rbxassetid://77422488155748",
        SkyboxFt = "rbxassetid://77422488155748",
        SkyboxLf = "rbxassetid://77422488155748",
        SkyboxRt = "rbxassetid://77422488155748",
        SkyboxUp = "rbxassetid://77422488155748"
    }
}

local currentSky = nil
local originalSky = nil
local skySystemEnabled = false

local autoChangerEnabled = false
local autoChangerConnection = nil
local autoChangerInterval = 10
local currentPresetIndex = 1

local function getPresetNames()
    local names = {}

    for name in pairs(skyPresets) do
        table.insert(names, name)
    end

    table.sort(names)

    return names
end

local presetNames = getPresetNames()

local function saveOriginalSky()
    local sky = Lighting:FindFirstChildWhichIsA("Sky")

    if sky and sky ~= currentSky then
        originalSky = sky:Clone()
    end
end

local function restoreOriginalSky()
    if currentSky then
        currentSky:Destroy()
        currentSky = nil
    end

    if originalSky then
        originalSky.Parent = Lighting
        originalSky = nil
    end
end

local function applySkyPreset(presetName)
    if not skySystemEnabled then
        return
    end

    local preset = skyPresets[presetName]

    if not preset then
        warn("Preset not found")
        return
    end

    if currentSky then
        currentSky:Destroy()
    end

    currentSky = Instance.new("Sky")
    currentSky.Name = "CustomSky"

    for face, asset in pairs(preset) do
        currentSky[face] = asset
    end

    currentSky.Parent = Lighting
end

local function cycleToNextPreset()
    currentPresetIndex += 1

    if currentPresetIndex > #presetNames then
        currentPresetIndex = 1
    end

    applySkyPreset(presetNames[currentPresetIndex])
end

local function startAutoChanger(interval)
    if autoChangerConnection then
        autoChangerConnection:Disconnect()
    end

    autoChangerEnabled = true
    autoChangerInterval = interval or 10

    local lastChange = tick()

    autoChangerConnection = RunService.Heartbeat:Connect(function()
        if not autoChangerEnabled then
            return
        end

        if tick() - lastChange >= autoChangerInterval then
            lastChange = tick()
            cycleToNextPreset()
        end
    end)
end

local function stopAutoChanger()
    autoChangerEnabled = false

    if autoChangerConnection then
        autoChangerConnection:Disconnect()
        autoChangerConnection = nil
    end
end

-- MASTER TOGGLE
SkyTab:CreateToggle({
    Name = "Enable Sky System",
    CurrentValue = false,
    Flag = "SkySystem",
    Callback = function(state)
        skySystemEnabled = state

        if state then
            saveOriginalSky()
            applySkyPreset("ScorpioHub")
        else
            stopAutoChanger()
            restoreOriginalSky()
        end
    end
})

-- SKY DROPDOWN
SkyTab:CreateDropdown({
    Name = "Custom Sky Preset",
    Options = presetNames,
    CurrentOption = "ScorpioHub",
    MultipleOptions = false,
    Flag = "SkyPreset",
    Callback = function(option)
        if typeof(option) == "table" then
            option = option[1]
        end

        applySkyPreset(option)

        for i, v in ipairs(presetNames) do
            if v == option then
                currentPresetIndex = i
            end
        end
    end
})

-- AUTO CHANGE
SkyTab:CreateToggle({
    Name = "Custom Change Sky",
    CurrentValue = false,
    Flag = "AutoSky",
    Callback = function(state)
        if state then
            startAutoChanger(autoChangerInterval)
        else
            stopAutoChanger()
        end
    end
})

-- CHANGE INTERVAL
SkyTab:CreateSlider({
    Name = "Change Interval",
    Range = {3, 60},
    Increment = 1,
    Suffix = " Seconds",
    CurrentValue = 10,
    Flag = "SkyInterval",
    Callback = function(value)
        autoChangerInterval = value

        if autoChangerEnabled then
            startAutoChanger(value)
        end
    end
})

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

SkyTab:CreateToggle({
    Name = "Name Tag",
    Callback = function()

        local function addTag(character)
            local head = character:WaitForChild("Head")

            -- remove old tag if it exists
            local old = head:FindFirstChild("DiscordTag")
            if old then
                old:Destroy()
            end

            local billboard = Instance.new("BillboardGui")
            billboard.Name = "DiscordTag"
            billboard.Adornee = head
            billboard.Size = UDim2.new(0, 200, 0, 50)
            billboard.StudsOffset = Vector3.new(0, 3, 0)
            billboard.AlwaysOnTop = true
            billboard.Parent = head

            local text = Instance.new("TextLabel")
            text.Size = UDim2.new(1, 0, 1, 0)
            text.BackgroundTransparency = 1
            text.Text = "ScorpioHub Arcade Basketball"
            text.TextColor3 = Color3.fromRGB(255, 0, 0)
            text.TextStrokeTransparency = 0
            text.TextScaled = true
            text.Font = Enum.Font.GothamBold
            text.Parent = billboard
        end

        if player.Character then
            addTag(player.Character)
        end

        player.CharacterAdded:Connect(function(character)
            task.wait(1)
            addTag(character)
        end)
    end
})

-- GOKU GOD AURA

local auraEnabled = false
local auraObjects = {}

SkyTab:CreateToggle({
    Name = "God Aura",
    CurrentValue = false,
    Flag = "GokuAura",
    Callback = function(state)

        auraEnabled = state

        local player = game.Players.LocalPlayer
        local character = player.Character

        if not character then return end

        local hrp = character:FindFirstChild("HumanoidRootPart")

        if not hrp then return end

        -- REMOVE AURA
        if not state then
            for _, obj in pairs(auraObjects) do
                if obj then
                    obj:Destroy()
                end
            end

            auraObjects = {}
            return
        end

        -- LOWER FIRE ATTACHMENT
        local attachment = Instance.new("Attachment")
        attachment.Name = "AuraAttachment"
        attachment.Position = Vector3.new(0, -3, 0)
        attachment.Parent = hrp

        table.insert(auraObjects, attachment)

        -- MAIN RISING FIRE
        local fire = Instance.new("ParticleEmitter")
        fire.Name = "GodAura"

        fire.Parent = attachment

        fire.Texture = "rbxassetid://284205403"

        fire.Rate = 400
        fire.Lifetime = NumberRange.new(0.7, 1.2)

        fire.Speed = NumberRange.new(10, 18)

        fire.VelocitySpread = 15

        fire.Acceleration = Vector3.new(0, 25, 0)

        fire.Drag = 2

        fire.LockedToPart = false

        fire.EmissionDirection = Enum.NormalId.Top

        fire.SpreadAngle = Vector2.new(25, 25)

        fire.Rotation = NumberRange.new(0, 360)
        fire.RotSpeed = NumberRange.new(-120, 120)

        fire.Size = NumberSequence.new({
            NumberSequenceKeypoint.new(0, 2.5),
            NumberSequenceKeypoint.new(0.4, 4),
            NumberSequenceKeypoint.new(1, 0)
        })

        fire.Transparency = NumberSequence.new({
            NumberSequenceKeypoint.new(0, 0.2),
            NumberSequenceKeypoint.new(0.7, 0.5),
            NumberSequenceKeypoint.new(1, 1)
        })

        fire.Color = ColorSequence.new({
            ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
            ColorSequenceKeypoint.new(0.5, Color3.fromRGB(255, 80, 80)),
            ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 180, 180))
        })

        table.insert(auraObjects, fire)

        -- SMALL ENERGY SPARKS
        local sparks = Instance.new("ParticleEmitter")
        sparks.Name = "AuraSparks"

        sparks.Parent = attachment

        sparks.Texture = "rbxassetid://243660364"

        sparks.Rate = 60
        sparks.Lifetime = NumberRange.new(0.3, 0.7)

        sparks.Speed = NumberRange.new(8, 15)

        sparks.Acceleration = Vector3.new(0, 15, 0)

        sparks.SpreadAngle = Vector2.new(360, 360)

        sparks.Size = NumberSequence.new(0.35)

        sparks.Transparency = NumberSequence.new({
            NumberSequenceKeypoint.new(0, 0),
            NumberSequenceKeypoint.new(1, 1)
        })

        sparks.Color = ColorSequence.new(Color3.fromRGB(255, 50, 50))

        table.insert(auraObjects, sparks)
    end
})

-- BASKETBALL GOD MODE TAB

local BasketballTab = Window:CreateTab("Basketball", 4483362458)

local Players = game:GetService("Players")
local Lighting = game:GetService("Lighting")

local LocalPlayer = Players.LocalPlayer

BasketballTab:CreateSection("Basketball God Mode")

-- REMOTES TABLE
local remotes = {
    steal = {},
    block = {},
    dunk = {},
    pass = {}
}

-- AUTO FIND REMOTES
for _, v in ipairs(game:GetDescendants()) do
    if v:IsA("RemoteEvent") then

        local name = v.Name:lower()

        if name:find("steal") then
            table.insert(remotes.steal, v)
        end

        if name:find("block") then
            table.insert(remotes.block, v)
        end

        if name:find("dunk") then
            table.insert(remotes.dunk, v)
        end

        if name:find("pass") then
            table.insert(remotes.pass, v)
        end
    end
end

-- AUTO STEAL
local function autoSteal()
    if #remotes.steal == 0 then return end

    for _, remote in ipairs(remotes.steal) do
        pcall(function()
            remote:FireServer("steal", true)
        end)

        pcall(function()
            remote:FireServer(1)
        end)
    end
end

-- AUTO BLOCK
local function autoBlock()
    if #remotes.block == 0 then return end

    for _, remote in ipairs(remotes.block) do
        pcall(function()
            remote:FireServer("block", true)
        end)

        pcall(function()
            remote:FireServer(100)
        end)
    end
end

-- AUTO DUNK
local function autoDunk()
    if #remotes.dunk == 0 then return end

    for _, remote in ipairs(remotes.dunk) do
        pcall(function()
            remote:FireServer("dunk", "perfect")
        end)

        pcall(function()
            remote:FireServer(100)
        end)
    end
end

-- BALL MAGNET
local function ballMagnet()
    local ball =
        workspace:FindFirstChild("Ball")
        or workspace:FindFirstChildWhichIsA("Part")

    if ball and LocalPlayer.Character then
        local hrp =
            LocalPlayer.Character:FindFirstChild("HumanoidRootPart")

        if hrp then
            ball.CFrame = hrp.CFrame + Vector3.new(0, 2, 1)
        end
    end
end

-- AUTO REBOUND
local autoReboundEnabled = false

local function autoRebound()

    if not autoReboundEnabled then
        return
    end

    local char = LocalPlayer.Character

    if not char or not char:FindFirstChild("HumanoidRootPart") then
        return
    end

    local hoop =
        workspace:FindFirstChild("Hoop")
        or workspace:FindFirstChild("Rim")

    if hoop then
        char.HumanoidRootPart.CFrame =
            hoop.CFrame * CFrame.new(0, -5, 3)
    end
end

-- AUTO PASS
local function autoPass()

    local nearestTeammate
    local char = LocalPlayer.Character

    if not char or not char:FindFirstChild("HumanoidRootPart") then
        return
    end

    local myPos = char.HumanoidRootPart.Position
    local minDist = math.huge

    for _, player in ipairs(Players:GetPlayers()) do

        if player ~= LocalPlayer
            and player.Team == LocalPlayer.Team
            and player.Character
            and player.Character:FindFirstChild("HumanoidRootPart") then

            local dist =
                (myPos - player.Character.HumanoidRootPart.Position).Magnitude

            if dist < minDist then
                minDist = dist
                nearestTeammate = player
            end
        end
    end

    if nearestTeammate and #remotes.pass > 0 then
        pcall(function()
            remotes.pass[1]:FireServer(nearestTeammate)
        end)
    end
end

-- TELEPORT TO BALL
local function teleportToBall()

    local ball =
        workspace:FindFirstChild("Ball")
        or workspace:FindFirstChildWhichIsA("Part")

    if ball
        and LocalPlayer.Character
        and LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then

        LocalPlayer.Character.HumanoidRootPart.CFrame =
            ball.CFrame + Vector3.new(0, 2, 0)
    end
end

-- FULL BRIGHT
local function fullBright(value)

    Lighting.Brightness = value and 5 or 2
    Lighting.ClockTime = 14
    Lighting.FogEnd = 100000
    Lighting.GlobalShadows = not value
end

-- LOOP SYSTEM
local activeLoops = {}

local function setFeature(tag, active, loopFunc)

    if active then

        if not activeLoops[tag] then

            activeLoops[tag] = true

            task.spawn(function()

                while activeLoops[tag] do
                    loopFunc()
                    task.wait(0.5)
                end
            end)
        end

    else
        activeLoops[tag] = nil
    end
end

-- TOGGLES

BasketballTab:CreateToggle({
    Name = "Auto Steal",
    CurrentValue = false,
    Flag = "AutoSteal",
    Callback = function(v)
        setFeature("steal", v, autoSteal)
    end
})

BasketballTab:CreateToggle({
    Name = "Auto Block",
    CurrentValue = false,
    Flag = "AutoBlock",
    Callback = function(v)
        setFeature("block", v, autoBlock)
    end
})

BasketballTab:CreateToggle({
    Name = "Auto Dunk",
    CurrentValue = false,
    Flag = "AutoDunk",
    Callback = function(v)
        setFeature("dunk", v, autoDunk)
    end
})

BasketballTab:CreateToggle({
    Name = "Ball Magnet",
    CurrentValue = false,
    Flag = "BallMagnet",
    Callback = function(v)
        setFeature("magnet", v, ballMagnet)
    end
})

BasketballTab:CreateToggle({
    Name = "Auto Rebound",
    CurrentValue = false,
    Flag = "AutoRebound",
    Callback = function(v)

        autoReboundEnabled = v

        setFeature("rebound", v, autoRebound)
    end
})

BasketballTab:CreateToggle({
    Name = "Full Bright",
    CurrentValue = false,
    Flag = "FullBright",
    Callback = function(v)
        fullBright(v)
    end
})

-- BUTTONS

BasketballTab:CreateButton({
    Name = "Auto Pass To Nearest Teammate",
    Callback = function()
        autoPass()
    end
})

BasketballTab:CreateButton({
    Name = "Teleport To Ball",
    Callback = function()
        teleportToBall()
    end
})

Embed on website

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