Play video content EXCLUSIVE

ESPN done messed up by dissing Kobe Bryant ... and they're gonna regret it ... so says Pat Riley.

TMZ Sports spoke with the NBA legend out in Malibu this week -- and Riley made it clear, the Mamba will have his revenge on the network for ranking him #40 on the list of the best players in the league.

Of course, Kobe took issue with the ranking himself -- calling ESPN a "bunch of idiots."

BONUS -- We also asked Riley about the key to maintaining his legendary hair ... and dude dished out some tips.