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

How do you remove everything in a player's backpack?

Asked by 5 years ago

So this is my script this is a rebirth now if you see in the code theres a child:remove() When i tested it it doesnt remove the child like how plz help im a nub at scripting :)

01local replicatedStorage = game:GetService("ReplicatedStorage")
02local StarterRebirthAmount = 60000
03local player = game.Players.LocalPlayer
04local mainframe = script.Parent:WaitForChild("MainFrame")
05local rebirthMenu = mainframe:WaitForChild("Frame")
06local mainbutton = script.Parent.MainButton
07local rebirthbutton = rebirthMenu:WaitForChild("Rebirth")
08local stregthnToRebirth = rebirthMenu:WaitForChild("Strenght")
09local rebirths = player:WaitForChild("leaderstats").Rebirth
10 
11wait()
12stregthnToRebirth.Text = "You need atleast "..math.floor((StarterRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).." balloons to rebirth"
13 
14mainbutton.MouseButton1Click:Connect(function()
15    mainframe.Visible = not mainframe.Visible
View all 48 lines...

All of you have a great night or day,God bless u

1 answer

Log in to vote
0
Answered by
mc3334 649 Moderation Voter
5 years ago

add in this:

1player.Backpack:ClearAllChildren()
2 
3for _,v in pairs(player.Character:GetChildren()) do
4    if v:IsA("Tool") then
5        v:Destroy()
6    end
7end)

The first line clears the backpack/inventory Anything following that will work to clear what's in the player's hand. Just make sure that player = the player you want to clear. You can add this anywhere to clear the inventory.

Ad

Answer this question