local player = game.Player.LocalPlayer
local button = <Button here>
button.MouseButton1Click:Connect(function()
for _, tool in ipairs(player.Backpack:GetChildren()) do
tool:Destroy()
end
end)
If you want to remove all the tools from the player’s backpack, then you can try this:
We will need to loop through both, the player’s backpack and the player’s character to find any tools - This is because whenever the player equips a tool, the tool will be parented under the character. Otherwise, it will be parented under the player’s backpack.
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Backpack = LocalPlayer:WaitForChild("Backpack")
local button = <Button here>
Button.Activated:Connect(function()
for _, child in ipairs(Backpack:GetChildren()) do
if child:IsA("Tool") then
child:Destroy()
end
end
for _, child in ipairs(Character:GetChildren()) do
if child:IsA("Tool") then
child:Destroy()
end
end
end)
I also suggest doing this on the server because to my knowledge, if you try to remove tools from the player’s backpack on the client, it won’t be replicated to the server. That means the server and the other players will still see the tools in either the player’s backpack or in the player’s hand.
If you are gonna try to do this on the client, you can use remote events to get the player.