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 3 years ago

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

1local plr = game:GetService('Players').LocalPlayer
2plr.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 3 years ago

This is probably what you are searching for:

1local plr = game:GetService('Players').LocalPlayer
2local backpack = plr:WaitForChild("Backpack")
3 
4for i, v in pairs(backpack:GetChildren()) do
5    if v:IsA("Tool") then
6        v:Destroy()
7    end
8end

Hope this helped!

0
Thanks for the answer I will see if it works:) Iownrobloxp 44 — 3y
Ad
Log in to vote
0
Answered by 3 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...

01local cooldown = false --//r
02local button = script.Parent
03local plr = game:GetService('Players').LocalPlayer
04local tool = game.ReplicatedStorage.ACS_Engine.HOOD["Micro UZI"]
05 
06button.Activated:Connect(function()
07    if cooldown == false then
08        cooldown = true
09    script.Parent.Parent.Visible = false
10    plr.Backpack:FindFirstChildWhichIsA('Tool'):Destroy()
11    local clone = tool
12    clone.Parent = plr.Backpack
13    wait(0.5)
14    script.Parent.Parent.Parent.ClassH.Visible = true
15    wait(3)
16        script.Parent.Parent.Parent.ClassH.Visible = false
17        cooldown = false
18        end
19    end)

I am going to replace

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

Answer this question