The distance from the sun at which this material can collect and form a terrestrial planet is influenced by a number of factors, including the presence of volatile materials, and the amount of radiation and heat being emitted by the star.
In general, terrestrial planets are thought to form within a habitable zone, which is a range of distances from a star where the temperature is just right for liquid water to exist on the surface of a planet. This zone is often referred to as the "Goldilocks zone," because it is not too hot and not too cold for life as we know it.
The inner boundary of the habitable zone is determined by the distance at which the temperature of the protoplanetary disk is too high for water ice to exist, while the outer boundary is determined by the distance at which the temperature of the disk is too low for water vapor to remain in the atmosphere.
Based on these factors, it is thought that terrestrial planets can form within a distance range of approximately 0.8 to 1.5 astronomical units (AU) from the sun. One AU is the average distance from the Earth to the sun, which is about 93 million miles.