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

How do I get a random part in a model?

Is there anyway that I can get just one random part of a model?

2 comments

0

Yes you can

0

How?

1 answer

✓ Accepted answer
local Parts = <model>:GetDescendants()
local RandomPart = Parts[math.random(1,#Parts)] -- GetDescendants returns an array, meaning you can index it like one.
print(RandomPart.Name) 

2 comments

0

What's the differences between :GetChildren() and :GetDescendants() ?

0

:GetChildren() returns an array of direct children. :GetDescendants() returns an array of children, and children of those children, etc.

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