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 pick a random brick?

What kind of function would let me pick a random brick from a model?

2 answers

✓ Accepted answer

Well you would have to get a table of all the children in the model, then use math.random on the table to get the random part.

Example;

AllDehParts = ModelOfParts:GetChildren() --Made a table of the parts

DatOnePart = (AllDehParts[math.random(1,#AllDehParts)])

--Use math.random on the table to get the random part, the arguments are just saying choose from 1 out of the total number there is, I know it looks confusing but it's not when you get the just of it.

Any questions I'll be happy to answer(:

-Goulstem

This script will get a random child from 'Model':

local model = game.Workspace.Model
local ranPart = model:GetChildren()[math.random(1,#model:GetChildren())]

Much simpler :P

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