Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make everything in backpack disapear? [UNSOLVED]

Is it possible to make an item in your backpack, go away, so you have an empty backpack? Anything I need to know before trying?

1 answer

✓ Accepted answer

You can iterate through all objects in the backpack and destroy each child, or use the ClearAllChildren method:

Game.Players["Player Name"].Backpack:ClearAllChildren();

Addition And to clear all players' backpacks:

local players = Game.Players:GetPlayers(); -- Get a table of all the players
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

6 comments

0

How could I do it so its not just players. I want it so when an event happens, everything in every players backpack is cleared

0

I altered my answers. I loop through and get each player and clear the children of their backpack.

0

Need to be in localscript?

0

Nope. But I suppose it could work in a localscript if filtering is not enabled.

0

what is filtering enabled and how do I enable and disable?

This discussion is preserved as it was. New answers, comments, and votes are closed.