In this work, the electrical, and optical properties are investigated for MgSc2Te4 and MgY2Te4 spinel compounds under the effect of pressure 5 to 10 GPa and 5 to 25 GPa, respectively. These compounds are suitable for optoelectronics and photovoltaic applications. Trans-Blaha modified Becke Johnson (TB-mBJ) approximation exchange and correlation capabilities were used to uncover electronic and optical properties. The electronic direct band gaps of both compounds appear to be direct despite the effect of pressure. MgSc2Te4 exhibits metallic behavior at 15 GPa, while MgY2Te4 exhibits metallic behavior at 30 GPa. Density of states spectra used to identify the atomic contribution of states by ions in the bands. The real part of the dielectric function, optical reflectivity and refractive index upshifted with the increase in energy while the imaginary parts of the dielectric function, optical conductivity and absorption coefficient redshifted with the increase of hydrostatic pressure.