So, you can buy legal semiautomatic firearms. You can even put the ammo feeding them on a belt - magazines of any capacity limit are not actually required by law in most states.
Today, open source software exists for all kinds of things, including various forms of machine vision. All the servos and control boards needed are readily available from websites like Pololu and Sparkfun.
Full autonomy would be an extremely difficult challenge, but it’s at least plausible that a small group of hobbyists could hack something together that worked under limited conditions. I think a high end infrared camera and machine vision could possibly detect human sized “intruders” in a bounded area. IFF would have to be something like a strobe flashing at a particular frequency, or maybe a phone app and bluetooth or something.
Would it be legal to build a killer robot that would open fire automatically on intruders in an area? I mean, you’d be insane to give a cobbled together collection of circuit boards and servos live ammo…but would it be legal?
Also, the servo on the killbot that pulls the trigger can actuate the trigger very frequently. Would this be considered a machine gun…?