5:24 PM PT -- Law enforcement sources tell TMZ two men were detained near the scene, but were later released and cleared by cops.
Gunshots rang out on the set of the TV show, "The Rookie" Thursday afternoon ... where you couldn't tell the difference between real and fake cops.
Production sources tell TMZ ... the show was filming outside Los Angeles Center Studios near downtown L.A. ... and moments ago someone ran by on foot and fired 3 shots that hit a building near the set location. There were people all around where the bullets hit. Thankfully, no one was injured.