You have to put that "if" clause inside a function and hook it to the "PLAYER_TARGET_CHANGED" event.
Here's what I use:
lua Code:
-- Create Target Border
function CreateTargetBorder(self)
local glowBorder = {edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1}
self.TargetBorder = CreateFrame("Frame", nil, self)
self.TargetBorder:SetPoint("TOPLEFT", self, "TOPLEFT", -1, 1)
self.TargetBorder:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 1, -1)
self.TargetBorder:SetBackdrop(glowBorder)
self.TargetBorder:SetFrameLevel(2)
self.TargetBorder:SetBackdropBorderColor(.7,.7,.7,1)
self.TargetBorder:Hide()
end
-- Raid Frames Target Highlight Border
function ChangedTarget(self, event, unit)
if UnitIsUnit('target', self.unit) then
self.TargetBorder:Show()
else
self.TargetBorder:Hide()
end
end
And then, inside raid style function:
lua Code:
CreateTargetBorder(self)
self:RegisterEvent('PLAYER_TARGET_CHANGED', ChangedTarget)