When a substance changes from a solid to a liquid, the density of the substance typically decreases. This is because, in most cases, solids are more densely packed than their liquid counterparts due to the intermolecular forces and structured arrangements in solids. As the substance transitions to a liquid, the molecules move apart slightly, leading to a decrease in density.
Thus, the correct answer is: D. the density of the substance decreases.