|
| 16 Sep 2015 06:31 PM |
Hey, I've been trying for a while now and I don't know why I'm so confused BUT how would I make a script that Destroys the children of the player puppyboy803.
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Sep 2015 06:32 PM |
game.Players.puppyboy803:ClearAllChildren() Unless you mean their character? |
|
|
| Report Abuse |
|
|
Scripth
|
  |
| Joined: 23 Jun 2013 |
| Total Posts: 1724 |
|
|
| 16 Sep 2015 06:33 PM |
function ClearAllChildren(obj) for i,v in next,obj:children() do v:Destroy() end end
ClearAllChildren() will not call :Destroy() so you need to create your own function to do so |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 16 Sep 2015 06:39 PM |
I thought it'd have to do something with(far wrong I know, but..)
puppyboy803 = game.Workspace.puppyboy803:GetChildren()
for i=1,#table do puppyboy803:Destroy() |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Sep 2015 06:40 PM |
puppyboy803 = game.Workspace.puppyboy803:GetChildren()
for i=1,#puppyboy803 do puppyboy803[i]:Destroy() end
Either one works, just different ways to do it. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
| |
|
|
| 16 Sep 2015 06:42 PM |
| Wouldn't I have to do the PlayerAdded function somewhere so that the script doesn't run before puppybyo803 joins? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 16 Sep 2015 06:43 PM |
| Well how do I do that part? |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 06:44 PM |
#code game.Players.PlayerAdded:connect(function(player) end)
#code return |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 06:52 PM |
game.Players.PlayerAdded:connect(function(player)
if Player.Name
puppyboy803 = game.Workspace.puppyboy803:GetChildren()
for i=1,#puppyboy803 do puppyboy803[i]:Destroy() end
end) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Sep 2015 06:54 PM |
Just do this, if you are removing all parts might as well remove their character.
game.Players.PlayerAdded:connect(function(player) local char = player.Character or player.CharacterAdded:wait(); char:Destroy(); end); |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 06:54 PM |
| I kind of wanted to learn how to do arrays though. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 06:55 PM |
#code local tab = {"woah",8,nil,true} for _,v in pairs(tab) do print(v) end
#code return |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 06:57 PM |
How far off is this?
game.Players.PlayerAdded:connect(function(player)
if Player.Name == 'puppyboy803' then
puppyboy803parts = game.Workspace.puppyboy803:GetChildren()
for i=1,#puppyboy803parts do puppyboy803parts[i]:Destroy()
end end end) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Sep 2015 07:00 PM |
The character is not going to be created right when their player is. You'll have to wait a bit, but other than that it seems fine. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 07:04 PM |
| It works, had to lower case the Player though. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 16 Sep 2015 07:12 PM |
| I did. Also, does anyone know something else I can do that's simple to learn Arrays? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Sep 2015 09:11 PM |
But when you actually wanna do it, use ClearAllChildren. Because it's better than looping and destroying and does use destroy |
|
|
| Report Abuse |
|
|