# Why does crystalline solids have well defined 3d geometry

Crystalline solids have well defined geometry because the intermolecular forces are uniform throughout the solid unlike amorphous solid where it varies from place to place.

But still the question hold why does some solids have this property like why $\ce{NaCl}$ forms a crystalline solid but not glass or something else.

I thought it is because crystalline solids are ionic but diamond is an counterexample among many.

Question :

Why does some solids have crystalline structure while others don't ?