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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 10 Sep 2013 10:39 PM |
| http://wiki.roblox.com/index.php/For_loop#For |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|