5:24 PM PT -- Law enforcement sources tell TMZ ... the men who were detained were 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.
Law enforcement sources tell us at least 2 people are believed to have fired the shots, and they were aimed toward the area where security officers were stationed.
We're told this is a known gang area, but there was no known conflict between security or anyone else before the shooting.
Although we don't know the motive, it appeared from a casual glance the area was filled with police officers.
We're told "The Rookie" star, Nathan Fillion, was on set.
Originally Published -- 4:05 PM PT