so say out of 10 bricks, you choose one brick by math.random, and you want to destroy the 9 bricks that aren't that one brick. how would you say that in lua?
01 | --First determine your set of bricks |
02 | local bricks = workspace.Bricks:GetChildren() |
03 |
04 | --Now chose one randomely |
05 | local brick = bricks [ math.random( 1 ,#bricks) ] |
06 |
07 | --Iterate through the table and remove the index if it doesn't match 'brick' |
08 | for _,v in next ,bricks do |
09 | if v ~ = brick then |
10 | v:Destroy() |
11 | end |
12 | end |