I am working on a game and the button that I have uses this code To remove a single tool
1 | local plr = game:GetService( 'Players' ).LocalPlayer |
2 | 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
This is probably what you are searching for:
1 | local plr = game:GetService( 'Players' ).LocalPlayer |
2 | local backpack = plr:WaitForChild( "Backpack" ) |
3 |
4 | for i, v in pairs (backpack:GetChildren()) do |
5 | if v:IsA( "Tool" ) then |
6 | v:Destroy() |
7 | end |
8 | end |
Hope this helped!
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...
01 | local cooldown = false --//r |
02 | local button = script.Parent |
03 | local plr = game:GetService( 'Players' ).LocalPlayer |
04 | local tool = game.ReplicatedStorage.ACS_Engine.HOOD [ "Micro UZI" ] |
05 |
06 | button.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
1 | plr.Backpack:FindFirstChildWhichIsA( 'Tool' ):Destroy() |