Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is It possible to :destroy() all of your tools in the starter pack with code?

I am working on a game and the button that I have uses this code To remove a single tool

local plr = game:GetService('Players').LocalPlayer
plr.Backpack:FindFirstChildWhichIsA('Tool'):Destroy()

I was wondering if I could expand on this and make it to were it would delete ALL tools in the starter pack. Thanks

2 answers

✓ Accepted answer

This is probably what you are searching for:

local plr = game:GetService('Players').LocalPlayer
local backpack = plr:WaitForChild("Backpack")

for i, v in pairs(backpack:GetChildren()) do
	if v:IsA("Tool") then
		v:Destroy()
	end
end

Hope this helped!

1 comment

0

Thanks for the answer I will see if it works:)

I forgot to mention I was going to add it into this code Its probably going to be hard so any help will be appreciated...

local cooldown = false --//r
local button = script.Parent
local plr = game:GetService('Players').LocalPlayer
local tool = game.ReplicatedStorage.ACS_Engine.HOOD["Micro UZI"] 

button.Activated:Connect(function()
	if cooldown == false then
		cooldown = true
	script.Parent.Parent.Visible = false
	plr.Backpack:FindFirstChildWhichIsA('Tool'):Destroy()
	local clone = tool
	clone.Parent = plr.Backpack
	wait(0.5)
	script.Parent.Parent.Parent.ClassH.Visible = true
	wait(3)
		script.Parent.Parent.Parent.ClassH.Visible = false
		cooldown = false
		end
	end)

I am going to replace

plr.Backpack:FindFirstChildWhichIsA('Tool'):Destroy()

This discussion is preserved as it was. New answers, comments, and votes are closed.