Help with Traitor King Macro

I used this macro below during WotLK classic to do the traitor king achievement, it is no longer working, always returns 0.

/run local count = 0 for i = 0, 10000, 1 do if _G[“NamePlate”…i] ~= nil and _G[“NamePlate”…i]:IsVisible() then count = count + 1 end end print(count)

I searched for similar macros, found this one, which seem to be more specific to just count the scarabs for the achievement, but it is also not working, only returning 0

/run local t,c,p=“Swarm Scarab”,0 for i=1,10000 do p=_G[“NamePlate”…i] if p and p:IsVisible() then c=c+(select(2,p:GetChildren()):GetRegions():GetText()==t and 1 or 0) end end print(t,“:”,c)

Can anyone help with this, please?

Instance Achievement Tracker will probably track it for you.

no, it does not, I have it

When I try your original macro in town with friendly nameplates on it returns different numbers (40, 23, etc).

/run local count = 0 for i = 0, 10000, 1 do if _G["NamePlate"..i] ~= nil and _G["NamePlate"..i]:IsVisible() then count = count + 1 end end print(count)

Do you have nameplates turned on?

Yes, I been using that macro for almost 2 years now, I ran several achievement runs to try for Traitor King

A friend of mine helped me out, this macro is working for me:

/run local count = 0 for _, plate in ipairs(C_NamePlate.GetNamePlates()) do local unit = plate.unitFrame.unit if plate:IsVisible() and UnitName(unit) == “Swarm Scarab” then count = count + 1 end end print(count)