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

Script will delete everything except what a player is holding, how to fix?

Asked by 7 years ago

I'm making a game that needs to delete EVERYTHING in the player's backpack once the map has deleted, but it deletes everything except what the player is holding.. How do I fix this??

Here is the script:

for key = 1, #players do -- Increment the key variable every iteration until it reaches the amount of players
    local value = players[key]; -- Create a reference to the player
    value.Backpack:ClearAllChildren(); -- Clear their backpack
end
0
btw before anyone asks, yes I used this script from someone else, but I can't figure out how to fix it ragingskull182 67 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
for _,v in pairs(plr.Character:GetChildren()) do
    if v:IsA("Tool") then
        v:Destroy()
    end
end
Ad
Log in to vote
0
Answered by
Zeloi 40
7 years ago

An easier alternative to what @Happywalker did would to use the:UnequipTools()


for key = 1, #players do local value = players[key] if value.Character and value.Character:FindFirstChild('Humanoid') then value.Character.Humanoid:UnequipTools() end value.Backpack:ClearAllChildren() end

Answer this question