Spencer Bergman, 13, holds his new dog Coconut as the family drives by the scene of the August robbery of Spencer's lemonade stand in Round Hill, Va. (J. Lawler Duggan/For The Washington Post)

All summer, Spencer Bergman was working toward his goal: Earn and save $500 so he could get a dog.

His mom purposely set the amount high; busy with four children and more-than-full-time work, she had said “no” to a dog forever. She and Spencer, who recently turned 13, figured it would take years to earn that much.

His longtime friend Spencer Tarbet, who’s 12 and lives in the house behind the Bergmans’ in the Loudoun County community of Round Hill, had a goal, too: Pay his share of scout camp.

They were closing down their lemonade stand one summer day when a young man, maybe 19 or 20, shirtless, smoking a cigarette, asked for change for a $20 bill — and walked away with all the money they had made that day, $35.

Spencer Bergman called after him and, when the man kept walking, called out again.

Spencer Bergman, Scott Kinney, Spencer Tarbet and Carter Tarbet outside Kinney’s Shamrock Music Shoppe in Purcellville, Va. Kinney and another employee helped comfort the boys after the robbery, including setting up a conference call with his brother, who wrote the best-selling "Diary of a Wimpy Kid" series. (Courtesy of Courtney Tarbet)

The man turned around, swore at the boys, and said if they ever told anyone he would beat them.

“My heart stopped,” Spencer Bergman said. It was the scariest thing that had ever happened to either of them, by far.

The incident was reported to Loudoun authorities, but no one has been arrested.

As the word got out, a growing community set about trying to make things right. It was as if everyone wanted to make sure that the world is still a place that’s safe for children with lemonade stands, where hard work matters, kids get puppies and people are kind to each other.

As August rolled into September, the boys received hundreds of dollars and an autographed book and pep talk from “Diary of a Wimpy Kid” author Jeff Kinney.

Round Hill is a small town near the Blue Ridge, with rocking chairs and pumpkins on porches. It is not supposed to be a place where thieves steal money from boys selling lemonade.

Bergman and Tarbet were crying when Courtney Tarbet arrived just a minute or two after the robbery to take her son to his first viola lesson, at the Shamrock Music Shoppe in nearby Purcellville.

Jen Wing, who manages lessons at the shop, saw Spencer’s tears, heard the story and gave him a “Wimpy Kid” book before he left. It was one of Spencer’s favorites, about a boy his age worrying about the bigger kids at middle school, like “gorillas who need to shave twice a day.”

It was written — and signed — by Kinney, whose brother Scott owns the music shop. Inside, Wing had slipped $15, and a note: “Spencer, please don’t lose faith in people.”

The boy burst into tears and gave his mom a long hug.

Then Spencer Tarbet gave the $15 gift to his friend. “For the dog,” he said.

When Paul Bergman got home from work at Verisign, he gave his son a wad of cash, $89: People at his office, overhearing his shocked reaction when his wife called to tell him about the crime, had opened their wallets.

The boys decided to have another lemonade stand in the same spot and joked that they would ask each customer for a photo ID and a fingerprint. Teachers and parents kept telling them, “Keep the change!” They earned $90.

At Scott Kinney’s suggestion, the boys also set up a stand outside the music store. Kinney posted a Facebook message urging his customers to stop by.

And Jeff Kinney video-called them. The author, who will publish the ninth book in the best-selling “Wimpy Kid” series this fall, told the boys about his own setbacks, and how he kept pushing forward with his idea for the first “Wimpy Kid” book despite years of rejections. He told them some secrets from the “Wimpy Kid” movies — Scott Kinney was the inspiration for the older brother Rodrick, who torments the main character and plays ghastly heavy metal.

He told them that as long as they kept trying to do the right thing, they’d be fine.

And he made them laugh when he suggested that Carter Tarbet, who is 10 and had left the lemonade stand moments before the crime, might be the real perpetrator: “Maybe he was in a disguise.”

The Kinneys gave each boy a $75 check. “My heart really went out to these kids,” Jeff Kinney said later. “My junior high years were really tough — to leave the safe cocoon of elementary school and go into what felt like the Wild West. Everyone wants to respond by showing these kids the better side of humanity.”

Suddenly, Spencer Bergman was unexpectedly close to his goal of $500.

“I was shocked at how nice and generous everyone was,” Spencer Tarbet said. He paid off the money for scout camp that he owed his parents, and he and his brother gave their friend more money toward the dog.

Spencer Bergman kept doing small jobs, thinking about how much he loved playing with his grandma’s little Shih Tzus, and the story “Where the Red Fern Grows” about a boy who saves to buy two dogs.

Last week, Lisa Bergman began adjusting to the idea that this dog thing might really happen.

Then a neighbor told them about a little Westie that needed a home.

“He came in and just started sniffing around and we loved him. He was just perrrrrrffffffffffect,” Spencer Bergman said.

Now, the money is going toward the care of the new family member.

Spencer’s sister and the Tarbet boys were piled on the sofa the other day with Coconut, who stretched onto his back to get a tummy rub. Spencer Bergman kissed Coconut’s head. He had already told his mom what the dog meant to him. It’s like his dad’s elk, he said, pointing to the trophy mounted in the living room. “It took him like 20 years to get. This isn’t just a dog.”

Spencer’s sister held up a treat to demonstrate a trick Coconut can do. “Come on, Coco, reach! Reach!”

Spencer Tarbet said, “Come on, Coco, you’ve got this!” When the dog jumped high enough to get the treat, stubby tail wagging, the kids clapped.

Lisa Bergman asked her son what he was going to do now that he had reached his goal. “Make a new one!” he said, scratching Coconut’s back.