My current code creates a 6x5 grid of tiles, with an array that stores each brick in the grid. My question is, how could I make it so a randomly selected brick is unanchored? I have a random number 1-30, but I'm not sure how I can use that random value to select the brick I want to unanchor.
for i=1,30, 1 do
Brick = Instance.new("Part")
Brick.Name = i
brickArray = {}
table.insert(brickArray, i)
Brick.Parent = workspace
Brick.Anchored = true
Brick.Size = Brick.Size + Vector3.new(20,0,22)
Brick.BrickColor = BrickColor.Random()
if i < 6 then
Brick.CFrame = CFrame.new(24*i,0,0)
elseif i < 12 then
Brick.CFrame = CFrame.new(24*(i-6),0,24)
elseif i < 18 then
Brick.CFrame = CFrame.new(24*(i-12),0,48)
elseif i < 24 then
Brick.CFrame = CFrame.new(24*(i-18),0,72)
elseif i < 30 then
Brick.CFrame = CFrame.new(24*(i-24),0,96)
end
print(brickArray[1])
end
local random = math.ceil(math.random(0,30))

5 comments
This worked after I corrected a few typos. Could I message you over Roblox or Discord or something though? I'm a little confused on how the top half actually works. Also, how do I clear up my unnecessary code?
K
my discord is greenhamster1
#8993
So basically you don't have much unnecessary code, you just should always look at easier methods to do things.