So my script is placing a tile with a different item on it on a 15x15 grid. First it selects the first row, then one of the squares in that row. It randomly selects a tile to place on that square, and it should place a square right there. It does, but it only places 5-9 squares and then i get an error "Attempt to index nil with 'Position'". This is the script I'm using.

UsableTiles = {game.ReplicatedStorage.Tiles.Berries_Tile, game.ReplicatedStorage.Tiles.Ore_Tile, game.ReplicatedStorage.Tiles.Tree_Tile, game.ReplicatedStorage.Tiles.Grass}
chosen = math.random(1, #UsableTiles)
rows = workspace.Grid:GetChildren()
for i = 1, #rows do
	selectedRow = rows[i]
	squares = selectedRow:GetChildren()
	for j = 1, #squares do
		chosen = math.random(1, #UsableTiles)
		Tile = UsableTiles[chosen]
		local copy = Tile:clone()
		copy.Parent = workspace.Inserted
		SelectedSquare = squares[j]
		desiredCFrame = CFrame.new(SelectedSquare.Position.X, SelectedSquare.Position.Y, SelectedSquare.Position.Z)
		copy:SetPrimaryPartCFrame(desiredCFrame)
		table.remove(squares, j)
		print(squares)
	end
end

Thank you for your help.