Morkah, my dude, thanks for the addon.
I watered down your code into this:
-- StartAutoAttack - Vanilla 1.12.1 / Lua 5.0
--
-- Adds two slash commands:
-- /start_auto_attack - begins auto-attack on your current target, if possible
-- /stop_auto_attack - stops auto-attack, if currently active ...