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?
COMMUNITY QUESTION
how to say "everything but a certain brick"?
1 answer
--First determine your set of bricks
local bricks = workspace.Bricks:GetChildren()
--Now chose one randomely
local brick = bricks[math.random(1,#bricks)]
--Iterate through the table and remove the index if it doesn't match 'brick'
for _,v in next,bricks do
if v ~= brick then
v:Destroy()
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
