Can you help with my Hunter Macro?

I grabbed this auto shot macro off of Kargoz, but I get this error;

“A macro script has been blocked from an action only available to the Blizzard UI”

this is the macro I tried to use

/script if GetUnitName(“target”)==nil then TargetNearestEnemy() end
/run if CheckInteractDistance(“target”, 3) and (not PlayerFrame.inCombat) then AttackTarget() elseif not IsAutoRepeatAction(3) then CastSpellByName(“Auto Shot”) end

Any thoughts or how to make this work for me?