Gudzyk pleaded guilty to attempted rape of a child, 15 counts of attempted unlawful communication with a minor and reckless endangerment for almost hitting a county detective with his car when he was arrested.

Gudzyk could face a maximum sentence of 21 to 42 years in prison and $30,000 in fines.

He will be sentenced after he is assessed by the state Sexual Offenders Assessment Board, and will undergo a psychiatric evaluation. He remains free on $250,000 bail.

Gudzyk admitted on the stand that he intended to meet what he thought was a 12-year-old girl for sex on Jan. 9. The Internet conversations were actually with an undercover detective.

"The plea is a good result because people could have been seriously hurt or injured that day," said Beatrice Lemanowicz, Montgomery County assistant district attorney.