NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 13 Dec 2011 04:46 PM |
| Is there a easy way to do this? Remove every item in a players backpack. |
|
|
| Report Abuse |
|
|
Merely
|
  |
| Joined: 07 Dec 2010 |
| Total Posts: 17266 |
|
|
| 13 Dec 2011 04:48 PM |
for i,v in ipairs(game.Players:GetPlayers()) do for index,value in ipairs(v.Backpack:GetChildren()) do value:Destroy() -- its the new fad end end |
|
|
| Report Abuse |
|
|
|
| 13 Dec 2011 04:48 PM |
In all or just one?
~Bikerking200 :P~ |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
| |
|
|
| 13 Dec 2011 04:53 PM |
for _,v in pairs(game.Players:children()) do for _,p in pairs(v.Backpack:children()) do p:Remove() end end ~Bikerking200 :P~ |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Dec 2011 04:55 PM |
Biker, if something is in Players that doesn't have a descendant named "Backpack" then that'll error. GetPlayers() returns a table with only players.
<'+1 Post. Ujelly?'> |
|
|
| Report Abuse |
|
|
|
| 13 Dec 2011 04:56 PM |
@Merely - There's also a new fad that does this shorter
game.Players:ClearAllChildren() |
|
|
| Report Abuse |
|
|
|
| 13 Dec 2011 04:57 PM |
Oh, Use Merely's code. Thanks Nate, now I know that.
~Bikerking200 :P~ |
|
|
| Report Abuse |
|
|
|
| 13 Dec 2011 04:57 PM |
Oh, all items in backpack.
for _,p in pairs(game.Players:GetPlayers()) do p.Backpack:ClearAllChildren() End |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 13 Dec 2011 04:57 PM |
| I just used Merely's. It will work correct? (I replaced :Destroy with :remove) |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 13 Dec 2011 04:58 PM |
'game.Players:ClearAllChildren()'
Y U KILL DA SERVER?! |
|
|
| Report Abuse |
|
|
|
| 13 Dec 2011 04:58 PM |
| @Neon - Remove is deprecated. Use Destroy instead |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Dec 2011 04:58 PM |
ClearAllChildren should ignore things like 'Terrain', as workspace:ClearAllChildren() = error. You would need to use pcall or an if statement to get it to not error.
<'+1 Post. Ujelly?'> |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 13 Dec 2011 04:59 PM |
What crazyman meant is;
for i, v in pairs(game.Players:GetPlayers()) do v.Backpack:ClearAllChildren() end |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 13 Dec 2011 04:59 PM |
| At crazyman, I think I'll just use yours (seems more shorter and efficient). |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
| |
|
|
| 13 Dec 2011 05:01 PM |
| Yes, use Spectrumw's. Apparently I think end's have capital E's today. I've been doing that all day |
|
|
| Report Abuse |
|
|
|
| 13 Dec 2011 05:02 PM |
Lol, Crazy, I know how you feel, with the capital E's with ends.
~Bikerking200 :P~ |
|
|
| Report Abuse |
|
|