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
 

How do I edit all of the children of a model?

Previous Thread :: Next Thread 
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
10 Sep 2013 10:30 PM
There's a group of objects. I want to edit one property of all of those objects on touch. I don't think "FindAllChildren" is a feasible thing (I tried it), and I couldn't find anything on the wiki. Help?

Essentially, I want this:

function onDrop(part)
script.Parent.FindAllChildren.Anchored = false
end

script.Parent.Touched:connect(onDrop)
Report Abuse
ilikepiehaha is not online. ilikepiehaha
Joined: 02 Aug 2011
Total Posts: 316
10 Sep 2013 10:32 PM
c = path-to-the-model-here:GetChildren()

for i=1, #c do
c[i].Anchored = false
end
Report Abuse
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
10 Sep 2013 10:36 PM
Any wiki page that would explain that? Most of it is new to me.
Report Abuse
ilikepiehaha is not online. ilikepiehaha
Joined: 02 Aug 2011
Total Posts: 316
10 Sep 2013 10:38 PM
Simple for-loop. Allow me;

c = path-to-the-model-here:GetChildren() -- this will be used in the next line

for i=1, #c do -- loops as many times as there are children of the model listed above
c[i].Anchored = false -- makes them all unanchored
end -- ends
Report Abuse
ilikepiehaha is not online. ilikepiehaha
Joined: 02 Aug 2011
Total Posts: 316
10 Sep 2013 10:39 PM
http://wiki.roblox.com/index.php/For_loop#For
Report Abuse
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
11 Sep 2013 09:23 AM
Ilikepie, tested it out. It didn't work, and the output window said:
attempt to perform arithmetic on global 'path' (a nil value)

And really, the top line is the part I don't get. I couldn't find any other way to get it to work.
Report Abuse
CrakTheRaven is not online. CrakTheRaven
Joined: 25 Dec 2009
Total Posts: 13410
11 Sep 2013 09:31 AM
script.Parent.Touched:connect(part)

for _,v in ipairs(script.Parent:GetChildren) do
if v:IsA("Part") then
v.Anchored = false
end
end
end
end)

Report Abuse
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
11 Sep 2013 06:06 PM
Crak, I thought this line looked weird:

for _,v in ipairs(script.Parent:GetChildren) do

And it's apparently invalid.
Report Abuse
blanman is not online. blanman
Joined: 15 Mar 2008
Total Posts: 1750
11 Sep 2013 06:15 PM
yeah, the for loop is tricky, but it's pretty handy. Keep trying examples until they work.
Report Abuse
Merilo is not online. Merilo
Joined: 01 Aug 2011
Total Posts: 500
11 Sep 2013 06:20 PM
Omg, hi Crak. Why are there so many old BRF players now in the scripting helpers forum??????
Report Abuse
laughablehaha is not online. laughablehaha
Joined: 19 Apr 2012
Total Posts: 2495
11 Sep 2013 06:21 PM
Okay, let's straighten this out: Put the script in the workspace service.

for i, v in ipairs(game.Workspace.YOURMODEL:GetChildren())
if v:IsA("Part") then
v.Anchored = true -- Vice Versa
end
end
Report Abuse
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
11 Sep 2013 06:32 PM
Laugh, yours was missing something, but I got it to work, thanks. I'll be messing around with it now and doing some stuff.
Report Abuse
laughablehaha is not online. laughablehaha
Joined: 19 Apr 2012
Total Posts: 2495
11 Sep 2013 06:34 PM
Your welcome

- Blame John
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