|
| 17 Nov 2016 10:15 PM |
So say I got a model in Work space with parts in it, and another model in it for fun
Work space > Model > Wood > Wood > Door > Doorframe > Doorframe > Doorself > Wood > Stone >
I know you can ClearAllChildren() but how do you make all the parts in the model get a transparency of 1 and can't collide. If the answer isn't simple, its okay I have an "Alternative" plan for my scheme... |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2016 10:17 PM |
for _, Obj in pairs(workspace.Model:GetChildren()) do if Obj:IsA("BasePart") then Obj.Transparency = 1 Obj.CanCollide = false end end |
|
|
| Report Abuse |
|
|
Salinas23
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 37141 |
|
|
| 17 Nov 2016 10:18 PM |
As far as I know you'd have to use a GetChildren() function, a for loop, and an if condition check for models inside models inside models.
Easiest thing to do would be to try using GetExtentSize(), convert it to Region3 somehow, and check for every part inside that region3
I have a spider on my back. |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2016 10:19 PM |
If you wanted to get the parts in the sub model, you'd have to use recursion.
http://wiki.roblox.com/index.php?title=Recursion |
|
|
| Report Abuse |
|
|
Praefor
|
  |
| Joined: 14 Nov 2016 |
| Total Posts: 258 |
|
|
| 17 Nov 2016 10:40 PM |
1.) Transparent parts are bad for performance.
2.)
local function applyToDescendants(object, callback) for _, child in pairs(object:GetChildren()) do callback(child) applyToDescendants(child, callback) end end
applyToDescendants(workspace.Model, function(child) if child:IsA("BasePart") then child.Transparency = 1 end end)
|
|
|
| Report Abuse |
|
|
|
| 17 Nov 2016 10:42 PM |
@praefor I decided that I am gonna do a better way, not have invisible parts. But thanks guys for the tips anyways! I may need it in the future |
|
|
| Report Abuse |
|
|
Salinas23
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 37141 |
|
|
| 17 Nov 2016 11:03 PM |
wait... is that a function calling the same function it is inside of?!? A dream within a dream... We must go deeper.
I have a spider on my back. |
|
|
| Report Abuse |
|
|
Praefor
|
  |
| Joined: 14 Nov 2016 |
| Total Posts: 258 |
|
|
| 17 Nov 2016 11:14 PM |
It's a technique known as "recursion", yep.
|
|
|
| Report Abuse |
|
|
Salinas23
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 37141 |
|
|
| 18 Nov 2016 05:33 AM |
That is actually really amazing and helpful and omg I cant wait to apply it on my game
I have a spider on my back. |
|
|
| Report Abuse |
|
|