This police booking photo released Thursday, Feb. 16, 2017 by the Horry County Police Department in Conway, S.C., shows Benjamin McDowell. McDowell is charged with being a felon in possession of a firearm. According to a sworn FBI statement, agents began investigating McDowell after he threatened a synagogue on Facebook and told an undercover agent he wanted to commit an attack in the "spirit of Dylann Roof." (Horry County Sheriff's Office via AP)

This police booking photo released Thursday, Feb. 16, 2017 by the Horry County Police Department in Conway, S.C., shows Benjamin McDowell. (Horry County Sheriff’s Office via AP)

*A white supremacist with felony convictions in South Carolina purchased a gun from an undercover FBI agent intending to attack a group of African Americans in “the spirit of Dylann Roof,” authorities said Thursday.

Benjamin McDowell, 29, was arrested in Myrtle Beach shortly after buying the .40-caliber Glock and ammunition for $109 from the agent who picked him up at his mother’s house, then took him to his grandfather’s house to get the money, FBI agent Grant Lowe wrote in an affidavit.

McDowell said he didn’t have a specific target in mind, once telling the undercover agent he might just shoot at a party of black people, Lowe wrote.

“I got the heart to do that s—, but I don’t have the good training,” McDowell said, according to the undercover agent.

McDowell is being held in the Horry County jail, charged as a felon in possession of a firearm.

Authorities opened an investigation on McDowell in December after he threatened a synagogue on Facebook. Horry County Police had kept track of McDowell since his release from prison on felony burglary charges a few years ago because he made connections with white supremacists while behind bars, according to the affidavit.

Several days after the threat, McDowell posted on Facebook again, saying fellow white supremacists were all talk and no action.

“All they wanne (sic) do is stay loaded on drugs the Jews put here to destroy white man and they feast on the drugs. they should be Feasting on the enemy that stole their Heritage and their bloodline and trying to run us off of this Earth,” McDowell wrote. “if you ain’t got the heart to fight for Yahweh like dylann roof did, you need to shut the f— up.”

Roof was sentenced to death in January on federal hate-crime charges for killing nine black worshippers at Emanuel AME church in Charleston in 2015.

McDowell also wrote he would like to buy a gun, which got the undercover agent involved, Lowe wrote.

McDowell wanted to commit the attack outside of Horry County and get away without being caught, but didn’t give a specific time or place, Lowe wrote.