St. Louis officials thought they had a sweet idea for improving the often tense relationship between the Police Department and the community.

The department had, for months, faced intense criticism for its handling of protests over the acquittal of a white police officer in the fatal shooting of a black man — not to mention years of scrutiny of its treatment of black residents in general. But now the city had a new public safety director and police chief, both of whom are black, and it was looking to turn a page.

So on Sunday night, Chief John Hayden announced on Twitter that his officers would give out candy to children from their patrol cars as a way to build relationships. “It’s the little things that often do the most good,” he wrote.

LaShell Eikerenkoetter, an activist in St. Louis, wrote on Twitter that this was not the type of community engagement that would build trust.

“These are the same officers that beat and terrorize the youth, now they’re going to give them candy?” she wrote. “No. They just will never get it.”

Police departments around the country regularly engage in relationship-building efforts that are of lighter fare. There’s coffee with a cop. Basketball in a park. The St. Louis Metropolitan Police Department even deploys an ice cream truck emblazoned with “Operation Polar Cops” on warm days.

The candy initiative was inspired by the childhood experiences of Jimmie Edwards, 62, a former judge who was sworn in as the city’s public safety director in November.

“It’s a gesture I hope that the children that will receive the candy today will be like I was,” he told The St. Louis Post-Dispatch. “I would try to outrace all the kids on my block to get to a police car because I knew I would get bubble gum and a baseball card.”

Mr. Edwards, who declined an interview request, was known for original approaches to working with youth as a judge. He helped to create the Innovative Concept Academy, the first school in the country overseen by the courts that aims to educate and rehabilitate juvenile delinquents.

Mr. Edwards told The Post-Dispatch that the candy initiative would not be a substitute for other efforts to connect with the community, and he joked that officers would distribute small amounts because, “I don’t need parents calling me about their dental bills.”

For many critics, that concern was no laughing matter.

“When it comes to parents and candy — eh,” said Sgt. Heather Taylor, the president of the Ethical Society of Police, the union representing black officers in St. Louis. “Candy is so different with our kids when we know that so many of them don’t have a meal.”

Cori Bush, an activist who is running for Congress, said that parents have long taught their children not to take candy from strangers, and that this initiative would run counter to that lesson. Telling children to make an exception for the police could be confusing, she said.

“Someone drives up” in a vehicle “that looks like a police car and says, ‘I want to give you candy,’” Ms. Bush said. “Are they able to discern: Is this an actual police officer or not?”

Although some people praised the department’s decision to distribute candy, the severe criticism led Chief Hayden to announce on Tuesday that the department would scrap the idea.