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

Backpack Script equals to false?

Asked by 11 years ago

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

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

The script returns to false. Why so?

3 answers

Log in to vote
1
Answered by 11 years ago

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

1for i,v in pairs(game.Workspace.Players.Username.Backpack:GetChildren()) do v:Destroy() end
0
You could simplify this by just use the ClearAllChildren method. User#11893 186 — 11y
0
@Kenetec You are right. Thank you. User#2263 0 — 11y
Ad
Log in to vote
2
Answered by 11 years ago

Fixed your errors:

1game.Players.PlayerNameHere.Backpack:ClearAllChildren()

But change PlayerNameHere to the players username

Log in to vote
0
Answered by 11 years ago

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

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

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

Answer this question