local UIS = game:GetService("UserInputService")
local PS = game:GetService("Players")
local Player = PS.LocalPlayer
local Grabbing = false
UIS.InputBegan:Connect(function(Input, GPE)
    if not GPE and Input.KeyCode == Enum.KeyCode.X then
        Grabbing = not Grabbing
        
        while Grabbing and task.wait(0.1) do
            for _, Target in next, PS:GetPlayers() do
                if Target.Character ~= nil and Target.Character ~= nil and Target.Character:FindFirstChild("Basketball") ~= nil then
                    pcall(function()
                        Player.Character.Humanoid:EquipTool(Target.Character.Basketball)
                    end)
                end
            end
                
            for _, Obj in next, Workspace:GetChildren() do
                if Obj:IsA("Tool") and Obj:FindFirstChild("Ball") ~= nil then
                    pcall(function()
                        Player.Character.Humanoid:EquipTool(Obj)
                    end)
                end
            end
        end
    end
end)