Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I select multiple children of a model?

Asked by 10 years ago

I am trying to unanchor all of the children of a model after 5 seconds. Here's that section of the script..

wait (5)
game.Workspace.Obstacle1.Children.Anchored = false

I tried on line 2. But it thought I was looking for a brick named Children. Help?

0
Check mine. HexC3D 830 — 10y
0
Try Again HexC3D 830 — 10y
0
Sorry for all the trouble, guys. SchonATL 15 — 10y
0
Should work HexC3D 830 — 10y
0
Check my answer again HexC3D 830 — 10y

2 answers

Log in to vote
0
Answered by
HexC3D 830 Moderation Voter
10 years ago
wait(10)
z = game.Workspace.Obstacle1:GetChildren() -- Get's the children
wait(2)
for i = 1,#z do -- Does on how many Children of Obstacle

z[i].Anchored = false -- Un- Anchors All of them
wait()
end

If this helped +1, if this answered check mark :)

0
This just made the whole thing fall immediately, just like the answer above. SchonATL 15 — 10y
0
It still just fell. Wait, to be clear, where should I put the script. Inside the model or would it be fine in Workspace? SchonATL 15 — 10y
0
Put it in workspace HexC3D 830 — 10y
0
It just wont work, did you test it? SchonATL 15 — 10y
View all comments (3 more)
0
DUDE I CAN FIX IT :P HexC3D 830 — 10y
0
Nothing is working D: SchonATL 15 — 10y
0
Wait, I was just looking through my questions, and I realized, the 1 in Obstacle1 is blue, maybe that effected the script? SchonATL 15 — 10y
Ad
Log in to vote
-1
Answered by
Sublimus 992 Moderation Voter
10 years ago

Use a for loop to access all the elements of a model:

wait(5) -- Wait 5
for _,v in pairs(game.Workspace.Obstacle1:getChildren()) do -- :getChildren will return a table of all the children of an object, the for _,v in pairs bit allows us to loop through each value, or object in the table
    if v.ClassName == "Part" then -- Make sure the current object is a part
        v.Anchored = false -- If it is a part, un-anchor it
    end -- End if statement
end -- End for loop
0
The whole thing fell immediately. SchonATL 15 — 10y
0
That's what you were trying to do correct, or did you want to wait 5 seconds between each part falling off? Sublimus 992 — 10y
0
I wanted it to wait 5 seconds, then the whole thing fall. Instead, that seemed to just ignore the "wait (5)" SchonATL 15 — 10y
0
If you are trying to test this when the game starts, it's not going to be an accurate wait time, try starting it with a longer wait time. Sublimus 992 — 10y

Answer this question