Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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!

0
Thanks for the answer I will see if it works:) Iownrobloxp 44 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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()

Answer this question