I know to clone tools into Backpack but I dont know how to destroy they afther. I mean I cant make :FindFirstChild(“tool”) inside Backpack and destroy it?
Do you want to remove all of them or just one?
For all of them:
local player = --path to player
local inventory = player.Backpack
for i,v in pairs(inventory:GetChildren()) do
if v.:IsA("Tool") then
v:Destroy()
end
end
Or you can call destroy for the tool you want.
Yes is something like that I guess
if youre cloning a tool and then destroy it , clone it like this:
local tool = (-tool path):Clone()
wait(3)
tool:Destroy – Example
local tool = RS.tool
local player = game.Players.LocalPlayer
local cloneTool = tool:Clone()
CloneTool.Parent = player.Backpack
wait(1)
–now I need to get it from Backpack
You can either call the Destroy()
method on the tool’s clone or you can reference the tool path and destroy it
only u need to type is
cloneTool:Destroy()
CloneTool is the same with different parents. No need to worry about it.
Ok I am working with one ImageButton and when I click on it he will clone one tool into Backpack but for destroy it I can use :FindFirstChild(“tool”)?
local tool = RS.tool
local player = game.Players.LocalPlayer
local cloneTool = tool:Clone()
CloneTool.Parent = player.Backpack
wait(1)
CloneTool:Destroy()
i dont recommend :FindFirstChild(“tool”) since youre said what tool means in the script , you can just :Destroy it
Oh ok now I understand because CloneTool parent is Backpack.
To remove all children from the backpack, use: Backpack:ClearAllChildren()
I used only for remove one tool and I did :FindFirstChild(“tool”):Destroy()