I have 30 anchored blocks. This script is intended to randomly select one block, and make it fall. It doesn't work though, and I can't figure out why.

Side note: I did assign CFrame positions to them all, I excluded them from the code below though because it's not relevant to the issue

	Tiles = Instance.new("Model")
	Tiles.Parent = game.Workspace
	Tiles.Name = "Tiles"
	Tiles.Archivable = true
	brickArray = {}
	
for i=1,30, 1 do
Brick = Instance.new("Part")
	Brick.Name = "Brick" .. i
	table.insert(brickArray, Brick.Name)
	Brick.Parent = game.workspace.Tiles
	Brick.Anchored = true
	Brick.Size = Brick.Size + Vector3.new(20,0,22)
	Brick.BrickColor = BrickColor.Random()
	Brick.Locked = false
end

while length >= 1 do
	i = math.ceil(math.random(1,length))
	print(i)
	v = brickArray[i]
	print(v)
		if v ~= nil then
		brickArray[i].Anchored = false
		game:GetService("Debris"):AddItem(v,"3")
	end
	wait(.2)
end

2 comments

0

Line 25 would error.

0

It does, as does everything having to do with v. I'm doing something wrong but I'm not sure how else to select the block out of the array