Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I select multiple children of a model?

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?

5 comments

0

Check mine.

0

Try Again

0

Sorry for all the trouble, guys.

0

Should work

0

Check my answer again

2 answers

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 :)

7 comments

0

This just made the whole thing fall immediately, just like the answer above.

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?

0

Put it in workspace

0

It just wont work, did you test it?

0

DUDE I CAN FIX IT :P

0

Nothing is working D:

0

Wait, I was just looking through my questions, and I realized, the 1 in Obstacle1 is blue, maybe that effected the script?

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

4 comments

0

The whole thing fell immediately.

0

That's what you were trying to do correct, or did you want to wait 5 seconds between each part falling off?

0

I wanted it to wait 5 seconds, then the whole thing fall. Instead, that seemed to just ignore the "wait (5)"

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.