sorry about it but i dont know how made it for _, tool in pairs(backpack:GetChildren()) do for _,tool in pairs(Inventory:GetChildren()) do if tool.Name == "Sword" then tool:Destroy() end
Try this
local player = game.Players.LocalPlayer for i,v in pairs(player.Backpack:GetChildren()) do if v.Name == "Sword" then v:Destroy() end end for i,v in pairs(player.Character:GetChildren()) do if v.Name == "Sword" then v:Destroy() end end
make sure the script is a local script or else this will not work.
local player = game.Players.LocalPlayer -- sets a variable for the client (which is invisible to the server that's why it must be local script. for _,v in pairs(player.Backpack:GetChildren()) do -- Gets every value (things) in the backpack if v.Name = "Sword" and v:IsA("Tool") then -- checks if the value's name is called Sword and makes sure it is a tool local sword = v -- sets a variable for the Sword sword.Equipped:Connect(function() -- does the following if the sword is equipped sword:Destroy() -- Deletus le sword end) end