This will call your function whenever the player target changes..
Lua Code:
frame:SetScript('OnEvent', function()
if UnitIsPlayer("target") then
frametext:SetText(UnitName("target"))
classtext:SetText(UnitClass("target") .. " " .. UnitRace("target"))
healthtext:SetText(UnitHealthMax("target") .. " Max HP")
partybutton()
end
end)
frame:RegisterEvent('PLAYER_TARGET_CHANGED')