Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!
Returns 1 if the first unit can attack the second, nil otherwise.
canAttack = UnitCanAttack(attacker, attacked);
- Bool - 1 if the attacker can attack the attacked, nil otherwise.
if ( UnitCanAttack("player", "target") ) then DEFAULT_CHAT_FRAME:AddMessage("You can attack " .. UnitName("target") .. "."); end
If the player can attack their target, a message stating so is displayed in the default chat frame.