whenallthepigsfly's answer is good, but has the flaw that you might get duplicate bricks (math.random might return the same number). If that's not okay in whatever you're doing, you should delete the brick from the table:
local bricks = game.workspace.Bricks:GetChildren()
local bricksChosen = {}
local numberOfBricksWanted = 2
for i = 1, numberOfBricksWanted do
if #bricks == 0 then break end
local index = math.random(1, #bricks)
bricksChosen[i] = bricks[i]
table.remove(bricks, i)
end
(Script is modified from whenallthepigsfly's answer. Note that in whenallthepigsfly's script, 'bricksChosen' is a table of integers, whereas mine is a table of the chosen bricks.)
1 comment
or, if someone has a better idea for a twinkle effect.