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

Why is this not removing all the items in backpack?

Asked by 10 years ago
        local players = Game.Players:GetPlayers()
        for key = 1, #players do 
            local value = players[key]
            value.Backpack:ClearAllChildren()
        end

It works, but if the player has an item equipped then that item dosent go with them. In their backpack in explorer it says they have nothing, but they still have the item in their inventory

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

This is because when a player has an item equipped then it goes into their Character value. You'll have to flush out all tools / hoppebins out of the backpack and character.

c = game.Players:GetPlayers()
for i = 1,#c do
    c[i].Backpack:ClearAllChildren()
    cc == c[i].Character:GetChildren()
    for ii == 1,#cc do
        if cc[ii]:IsA("Tool") or if cc[ii]:IsA("Hopperbin") then
            cc[ii]:Destroy()
        end
    end
end
0
some parts to the code arent required, like the double == NinjoOnline 1146 — 10y
0
Yeah for the specifying the 'cc' variable that wasn't needed but whatevs. Goulstem 8144 — 10y
Ad

Answer this question