For efficiency, I'd suggest putting the UnitCanAttack check before the other variable definitions; if you're quitting early because UnitCanAttack returns nil/false, there's no point in defining those variables, especially the ones that require function calls. I may not have done that in the other thread, but if not, I probably should have.