A month before a gunman murdered 20 people in an El Paso Walmart, a grandmother was able to stop another potential mass shooting in Texas — by her grandson.

William Patrick Williams, a 19-year-old from Lubbock, told his grandmother in July he had bought an AK-47, and planned to “shoot up” a hotel and then take his own life, according to the U.S. Attorney’s Office of the Northern District of Texas.

Citing her concern for his well-being and the safety of others, his grandmother was able to convince Williams to go to a hospital to get treatment, authorities said.

William Patrick Williams was charged with making false statements to a firearms dealer in Lubbock, Texas, on Aug. 1, 2019. Lubbock County Jail via AP

When police searched the hotel room Williams had rented, they found the weapon he had told his grandmother he possessed, along with 17 loaded magazines, and multiple knives. They also found black tactical pants, a black trench coat and a black T-shirt that read “Let ‘Em Come.”

“This was a tragedy averted,” said U.S. Attorney Nealy Cox. “I want to praise the defendant’s grandmother, who saved lives by interrupting this plot.”

After looking into the forms Williams filled out to purchase the weapon, police said he appeared to list false information on the forms and allegedly misrepresented his address. On Thursday, he was arrested by the Bureau of Alcohol, Tobacco, Firearms and Explosives and the FBI for making false statements to a firearms dealer.

Williams appeared in court on Friday, and authorities say he could face up to five years in federal prison.