Kodak Black was scolded by a judge as he was sentenced to 46 months in prison on federal firearms charges.

According to a report from the South Florida Sun-Sentinel, U.S. District Court Judge Federico Moreno made it a point to let the rapper know that he was not pleased with his criminal history.

“Young people do stupid things,” the judge told the 23-year-old. “But the problem is that you’ve been doing stupid things since you were 15.”

While Kodak’s lawyer, Bradford Cohen, admitted that the rapper—who grew up in the Golden Acres public housing project in Broward, Florida—has had multiple run-ins with the law since his early teens, he said some of his client’s past crimes were misunderstood.

Cohen said Black was once charged with robbery and kidnapping, but that was after five individuals robbed his mother’s home.

Black rounded up the would-be robbers from the neighborhood, took their cellphones and brought them back to his mom’s house to apologize to her.

The reason why Black was in court this time was because he lied about his criminal record while purchasing (or trying to purchase) six pistols on two separate occasions at a Miami-area gun shop.

One of the weapons was later found at the scene of a shooting in Pompano Beach in March.

Before receiving his sentence, the “ZEZE” rapper apologized and said he held himself accountable for his actions.

“I’m sorry for the actions that led me for where I’m standing,” Kodak said. “I do take full responsibility for my mishap.”

Prior to the judge revealing Kodak’s sentence, prosecutors revealed that the rapper—whose real name is Bill Kapri—was recently involved in a nasty prison fight that sent a guard to the hospital and required him to have surgery.

“Kapri displayed disruptive behavior,” said Assistant U.S. Attorney Bruce Brown. “He was involved in a fight on October 29th with another inmate.”

After being pepper-sprayed by the corrections officer, Black punched the guard twice and then grabbed his testicles, holding on “to the point where his abdomen and intestinal wall were breached,” an FBI agent testified.

Black was reportedly under the influence of drugs at the time, and it took four officers to restrain him, the federal agent said.

The rapper’s attorneys believe he was drugged and tricked into the altercation by a gang member.