First, I'm scratching my head why some responders suggested that after arriving at Heathrow you should then travel into London to take the train to Edinburgh when you could easily take a flight from Heathrow to Edinburgh?
With your two options, there is a lot to consider. Is there a big cost difference between the two? Do you mind longer flights?
Personally, I would take the direct flight LAX to London and then switch to a flight to Edinburgh.
If you take the flight from LA to NY and it is late making you miss the flight the Edinburgh, there may not be another flight until the next day unless they route you through London or somewhere else.
But if your flight from LAX into Heathrow is late, there are numorous flights from there to Edinburgh daily.
Buy it all on one ticket so you are covered in case of problems. Buy direct from the airlines. Not a third party.
If you fly British Airways the entire way, all flights will be in and out of Terminal 5 at Heathrow.