UnitSex

From Wowpedia
Jump to: navigation, search

Returns the gender of the specified unit.

gender = UnitSex(unit)

Arguments

unit 
string - UnitId

Returns

sex 
number (nilable) - One of the following values, or nil if the unit does not exist
  • 1 = Neutrum or Unknown
  • 2 = Male
  • 3 = Female

Example

local genders = {"unknown", "male", "female"}
if UnitExists("target") then
	print("The target is "..genders[UnitSex("target")])
end

Details

  • Most non-humanoid mobs/creatures will appear as Neutrum/Unknown.
  • Player characters currently appear as either Male or Female.

Patch changes

Previously returned 0 male, 1 female, 2 unknown
  • At an unknown time after 1.10, sheeped targets stopped returning 'unknown' and began providing the 'true' gender

See also

External Links