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?
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?
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
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.
2 comments
You could simplify this by just use the ClearAllChildren method.
@Kenetec You are right. Thank you.