South Florida rapper Kodak Black was sentenced to three years and 10 months in federal prison on Wednesday.

U.S. District Court Judge Federico Moreno sentenced the rap star for lying about his criminal record while purchasing or trying to purchase six pistols on two separate occasions at Lou’s Police and Security Equipment in Hialeah.

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

Before his sentence was handed down, Kodak accepted responsibility for his crimes. “I’m sorry for the actions that led me for where I’m standing,” said the artist, who grew up in Pompano Beach’s Golden Acres housing development. "I do take full responsibility for my mishap.”

The rapper, dressed in a khaki inmate’s uniform, was flanked by his two lawyers and two U.S. Marshals in the courtroom.

Kodak, whose 2018 album “Dying to Live” debuted at No. 1 on the billboard charts, has been in custody at the federal detention center in Miami since his arrest before the rolling loud music festival last May. Today, he shuffled back and forth on his feet before the judge while waiting for the penalty.

Before the sentence was handed down, prosecutors revealed that Kodak, whose legal name is Bill Kapri, had recently been in a nasty prison fight.

“Kapri displayed disruptive behavior," said Assistant U.S. Attorney Bill Brown. “He was involved in a fight on Oct. 29, with another inmate." A corrections officer stepped in, spraying mace on both inmates.

Prosecutors said Kodak was visibly under the influence of an unknown substance when he viciously assaulted the officer who intervened, beating the officer in the face and groin so badly that the guard ended up in the hospital with a hernia.

Kodak’s lawyers disputed the facts of the melee, suggesting that Kodak was drugged and tricked into the altercation by a gang member.

The judge ultimately decided that the violent dispute couldn’t be factored into the sentence Kodak was to be given. But the judge did factor in the fact that one of the guns Kodak purchased from the weapons shop was found at the scene of an apparent Pompano shooting last March.

Court documents state that the gun was jammed, loaded with live ammunition, and bore Kodak’s fingerprints. Court documents also allege that the intended target of the shooting was a rival rap artist, though the documents do not reveal the target’s identity.

The documents do state, however, that a Porsche Panamera rented by Kodak was at the scene at the time of the altercation. Authorities didn’t charge Kodak in the shooting.

Kodak purchased that weapon, a Sig model MPZK9 automatic pistol, which looks more like an Uzi than a handgun, and two others at the Hialeah gun shop on February first. While buying the guns, he wrote down an incorrect Social Security number and marked “no” on the sections of a federal form that asked if he was ineligible to buy a gun.

But Kodak was already under indictment and out on bond in a separate criminal case in South Carolina when he purchased the handguns. He would not have been allowed to buy the weapons had he been truthful on the form.

He then returned to the gun store a month later and attempted to purchase another three weapons. This time, he put in his correct social security number, but still stated that he was eligible to purchase the guns on the required federal form.

Kodak’s lawyers had asked the judge for a three-year sentence, while prosecutors were asking that the rapper be given over eight years in prison, given the recent violent altercation.

Kodak also still has other pending criminal cases. One involves the 2016 alleged sexual assault of an adult aged high-school female in Florence, South Carolina, which made him ineligible to purchase the weapons in the first place.

Another case involves drugs and guns and that were found in Kodak’s car as he and his entourage crossed into Canada for a show last April.

“This is going to be the longest sentence that he’s going to get in his career, hopefully his life," noted Brad Cohen, Kodak’s defense attorney.

Prosecutors indicated that they intend to bring Kodak’s prison fight before a grand jury. An indictment against Kodak for his alleged assault of a prison guard would only add to his significant legal troubles.