KANSAS CITY, Mo. — A southwest Missouri man accused of plotting attacks at a movie theater and Walmart was able to legally buy the guns he allegedly planned to use, despite being forced to undergo a psychiatric evaluation three years ago for stalking a store clerk he said he intended to kill, authorities said.

Blaec Lammers, 20, was arrested last week after his mother told police that she feared he was planning an attack. Investigators who questioned him last Thursday say he said he had bought a ticket to the latest ‘‘Twilight’’ movie on its opening weekend and planned to open fire on filmgoers before going to a nearby Walmart to shoot shoppers.