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

Why is this not removing all the items in backpack?

	    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

✓ Accepted answer

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

2 comments

0

some parts to the code arent required, like the double ==

0

Yeah for the specifying the 'cc' variable that wasn't needed but whatevs.

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