Help me writing a PlayerFrame code to fade in

Hello, I am currently using the code here which I found on US forums;

Then I’ve added TargetFrame for more immersion;

PlayerFrame:SetAlpha(0.05)
EventRegistry:RegisterCallback("PLAYER_REGEN_DISABLED", function() 
	PlayerFrame:SetAlpha(1)
end)

EventRegistry:RegisterCallback("PLAYER_REGEN_ENABLED", function() 
	PlayerFrame:SetAlpha(0.05)
end)

PlayerFrame:HookScript("OnEnter", function(self)
	self:SetAlpha(1)
end)

PlayerFrame:HookScript("OnLeave", function(self)
	if not InCombatLockdown() then
		self:SetAlpha(0.05)
	end
end)

TargetFrame:SetAlpha(0.2)
EventRegistry:RegisterCallback("PLAYER_REGEN_DISABLED", function() 
	TargetFrame:SetAlpha(1)
end)

EventRegistry:RegisterCallback("PLAYER_REGEN_ENABLED", function() 
	TargetFrame:SetAlpha(0.2)
end)

TargetFrame:HookScript("OnEnter", function(self)
	self:SetAlpha(1)
end)

TargetFrame:HookScript("OnLeave", function(self)
	if not InCombatLockdown() then
		self:SetAlpha(0.2)
	end
end)

Now, I want to make PlayerFrame’s Alpha to 1 when i target myself but couldn’t find a way to do it.

Tried UnitisUnit but couldn’t make it work, Tried OnEvent with UNIT_TARGET: “player” too, it didn’t work neither. Also tried;

EventRegistry:RegisterCallback("PLAYER_TARGET_CHANGED", function()
    if ( UnitIsUnit("targettarget", "player") ) then
      PlayerFrame:SetAlpha(1)
end)

I have no clue about coding etc. just tried some codes with some common sense and probably making some mistakes but don’t even know what it is my mistakes. I don’t know how I can call TargetPlayer to SetAlpha(1) in this coding language.

If someone with coding knowledge can help, it will make my day.

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