generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Removing all players items?

Previous Thread :: Next Thread 
NeonBlox is not online. 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 is not online. 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
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
13 Dec 2011 04:48 PM
In all or just one?

~Bikerking200 :P~
Report Abuse
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
13 Dec 2011 04:51 PM
At Biker, all players.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
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 is not online. 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
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
13 Dec 2011 04:56 PM
@Merely - There's also a new fad that does this shorter

game.Players:ClearAllChildren()
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
13 Dec 2011 04:57 PM
Oh, Use Merely's code. Thanks Nate, now I know that.

~Bikerking200 :P~
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
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 is not online. 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 is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
13 Dec 2011 04:58 PM
'game.Players:ClearAllChildren()'

Y U KILL DA SERVER?!
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
13 Dec 2011 04:58 PM
@Neon - Remove is deprecated. Use Destroy instead
Report Abuse
nate890 is not online. 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 is not online. 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 is not online. 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 is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
13 Dec 2011 05:00 PM
Or do I use Spectrum's?
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
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
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
13 Dec 2011 05:02 PM
Lol, Crazy, I know how you feel, with the capital E's with ends.

~Bikerking200 :P~
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image