A man has been charged with child endangerment after a 12-year-old boy shot himself while playing with a gun in Rosemoor on the South Side.

Willie Richard, 55, is charged with two felony counts of unauthorized use of a weapon, one felony count of being an armed habitual criminal and a misdemeanor count of child endangerment, Chicago police said.

Richard, of south suburban Crete, allegedly owned the gun the boy had been playing with before it went off on Sunday, striking the boy in the hand, police said.

The boy initially told police he was in an alley about 11:30 a.m. in the 9500 block of South Calumet Avenue when he heard a gunshot and felt pain in his hand, police said. Someone took him to Roseland Hospital where he is in good condition.

Officers investigating the alley where the shooting occurred found a vehicle with a gun and a spent shell casing inside, police said. The boy later admitted that he had been playing with his father’s gun when it went off inside the vehicle, striking him in the hand.

Judge Susana Ortiz set Richard’s bail at $50,000 during a hearing Tuesday, according to Cook County court records. His next court date was set for July 15.

Read more on crime, and track the city’s homicides.