Help with toggle party script/addon

Dear friends, I am trying to write an addon which lets me toggle the default party frames. Here is the core of it:

if PartyMemberFrame1:IsVisible() then PartyMemberFrame1:Hide(); else PartyMemberFrame1:Show(); end
if PartyMemberFrame2:IsVisible() then PartyMemberFrame2:Hide(); else PartyMemberFrame2:Show(); end
if PartyMemberFrame3:IsVisible() then PartyMemberFrame3:Hide(); else PartyMemberFrame3:Show(); end
if PartyMemberFrame4:IsVisible() then PartyMemberFrame4:Hide(); else PartyMemberFrame4:Show(); end

However, if there is less than 4 other members, the icons for disconnected members appear. Any ideas of how to fix this? Can one somehow record the number of party members, then do a couple of if-codes?

Any input appreciated!

Something like this should work

for i = 1, MAX_PARTY_MEMBERS do
	local f = _G["PartyMemberFrame"..i]
	if UnitExists("party"..i) then
		f:Show()
	else
		f:Hide()
	end
end
1 Like

aaah thanks alot! I did not know about if UnitExists.

Edit: It reproduced the same problem though, but I changed hide to set alpha instead, which worked ok.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.