My hard drive is broken on my Mac, I have a new one, but how can I install OS X?
You can purchase Snow Leopard from Apple for $19.00US and install it from a optical disk reader. Once Snow Leopard is installed, (it needs to be v.10.6.8,) upgrade to Yosemite through the App Store. Make sure your MacBook is not too new to run Snow Leopard, though.