Getty
Exclusive

Kodak Black On Sober Path for Rolling Loud ... Teamwork Kept Him Clean

Kodak Black lit up the stage at Rolling Loud California ... but we've learned it took a lot of work behind the scenes to make sure he stayed sober leading up to his performance.

Kodak's performance at the 3-day music festival was his last hoorah before he enters in-patient rehab next week. His lawyer, Bradford Cohen, tells TMZ Hip Hop ... the artist was in L.A. with a full team of folks making sure they steered him clear of any bad influences.

We're told that team included a physician to look after his eating habits, and another person was designated to be by his side at all times and ensure he stayed on the straight and narrow.

Cohen says the "Super Gremlin" rapper doesn't usually do the after-party scene, so that was one less thing to worry about while he was in La-La Land.

ICYMI, a Florida judge ordered KB to 30 days of inpatient rehab after authorities claimed he violated his bail conditions by testing positive for fentanyl.

You'll recall, Kodak was busted in Ft. Lauderdale back in July for possession of a controlled substance without a prescription and drug trafficking ... after cops say they found upwards of 31 oxycodone pills in his car.

With a successful Rolling Loud appearance behind him, we're told he's now focused on getting treatment in rehab.

Click here for info about our online advertising practices.