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 » Scripters
Home Search
 

Re: Array help

Previous Thread :: Next Thread 
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
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 is not online. 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 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
16 Sep 2015 06:36 PM
Still...
Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
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 is not online. 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 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
16 Sep 2015 06:41 PM
make ur variables local
Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
16 Sep 2015 06:42 PM
Well yes
Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
16 Sep 2015 06:43 PM
Well how do I do that part?
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
16 Sep 2015 06:44 PM
#code
game.Players.PlayerAdded:connect(function(player)

end)


#code return
Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
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 is not online. 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
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
16 Sep 2015 06:54 PM
I kind of wanted to learn how to do arrays though.
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
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
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
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 is not online. 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
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
16 Sep 2015 07:04 PM
It works, had to lower case the Player though.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
16 Sep 2015 07:05 PM
Test it online now :)
Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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