|
How would I go about destroying all the items under StarterGear?
I don't need to remove or clearallchildren.
I really need to destroy them all at once.
Thanks in advance awesome scripters.
Raise your DONGERS (ง ° ͜ ʖ °)ง?!?!? -Pixel Vibez |
|
|
Why wouldn't you use ClearAllChildren()? It's the same as destroying each child of StarterGear. Otherwise, I don't really understand what you're saying.
~MightyDantheman |
|
|
Clearallchildren "removes" not "destroys".
I have to use the destroy() method
Raise your DONGERS (ง ° ͜ ʖ °)ง?!?!? -Pixel Vibez |
|
|
|
for _, v in ipairs(StarterGear:GetChildren()) do
v:Destroy()
end |
|
|
|
Right but I don't know how his script is set up so I put that there in place of a variable he might be using. |
|
cgjnmJoin Date: 2011-12-22 Post Count: 2347 |
StarterGear?
You mean game.StarterPack, game.StarterGui, game.StarterPlayer, player.Backpack, player.PlayerGui?
Or what do you mean? |
|
cgjnmJoin Date: 2011-12-22 Post Count: 2347 |
But whatever it is, do this:
repeat wait() until #StarterGear:GetChildren() > 0
for i,v in pairs(StarterGui:GetChildren())do
v:Destroy()
end |
|
|
Sorry for the late reply, first of all thanks for all the help guys! BUT unfortunately none of the answers have worked this far the output error I keep getting is:
Players.Player1.Backpack.Angel.EatScript:27: attempt to index a nil value
I'd say StarterGear is nil in some way? Is there anyway I can fix that?
Raise your DONGERS (ง ° ͜ ʖ °)ง?!?!? -Pixel Vibez |
|
|
Bump
Raise your DONGERS (ง ° ͜ ʖ °)ง?!?!? -Pixel Vibez |
|
spinywindJoin Date: 2012-01-26 Post Count: 3580 |
local Children = script.parent.Startergear:GetChildren()
local x = AMOUNT OF CHILDREN
for i = x, #Children do
i, Children[11]:Destroy()
end
asuming this is in workspace
|
|
|
What's the difference between remove and destroy... |
|
|
Remove -If the object is referenced before being removed it is possible to retrieve the object at a later point.
Destroy -Sets the Parent property to nil, locks the Parent property, disconnects all connections and calls Destroy() on all children.
Raise your DONGERS (ง ° ͜ ʖ °)ง?!?!? -Pixel Vibez |
|
|
Bump
Raise your DONGERS (ง ° ͜ ʖ °)ง?!?!? -Pixel Vibez |
|
OzzyFinJoin Date: 2011-06-07 Post Count: 3600 |
ClearAllChildren uses destroy even if wiki states otherwise
local part = workspace.Model.Part
workspace.Model:ClearAllChildren()
part.Parent = workspace
>error |
|
|
I've been using Clearallchildren but it's not working so well for the script.
I believe destroy would fix the problems, that's why i'm trying to use it.
That being said, bump.
Raise your DONGERS (ง ° ͜ ʖ °)ง?!?!? -Pixel Vibez |
|
|
Why does it matter if it can be retrieved later? |
|
|
?? Do you want to empty what is in the players backpack?
game.Players.LocalPlayer.BackPack:GetChildren() should work just fine.
|
|