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

Backpack Script equals to false?

I have a backpack script. It's suppose to make everything in the backpack be removed.

game.Workspace.Players.Username.Backpack:remove()

The script returns to false. Why so?

3 answers

✓ Accepted answer

You do not want to remove the backpack itself, just the children in it.

for i,v in pairs(game.Workspace.Players.Username.Backpack:GetChildren()) do v:Destroy() end

2 comments

0

You could simplify this by just use the ClearAllChildren method.

0

@Kenetec You are right. Thank you.

Fixed your errors:

game.Players.PlayerNameHere.Backpack:ClearAllChildren()

But change PlayerNameHere to the players username

You tried to remove the backpack. Instead, remove its children.

children = game.Workspace.Players.Username.Backpack:GetChildren()
for k, child in pairs(children) do
	if child:IsA('Part') and not child.Locked then
		child:Destroy()
	end
end

Should be something like that. If it doesn't work, sorry about that. I got it off the wiki and modified it slightly.

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