I had a semicolon in a bad spot. I ended up rewriting the code to use OnUpdate because each UnitFrame has a lot of children that made the OnEnter/OnLeave scripts fire erratically.
Lua Code:
-- Configuration
local ShowAlpha=1;
local HideAlpha=0.05;
-- Visibility logic
local function UnitFrame_UpdateVisibility(self)
self:SetAlpha(
(
InCombatLockdown()-- Check combat
or UnitIsUnit("target","player")-- Check targeting self
or self:IsMouseOver()-- Check mouseover
) and ShowAlpha or HideAlpha
);
end
PlayerFrame:HookScript("OnUpdate",UnitFrame_UpdateVisibility);
TargetFrame:HookScript("OnUpdate",UnitFrame_UpdateVisibility);
For future reference, script errors are turned off by default. You can enable them by typing this command into chat.
Code:
/console scriptErrors 1
Also
local limits the visibility of a function/variable to a specific blocks of code referred to as its "scope". This is in contrast to "globals", which can be accessed by anyone. It's recommended to use locals whenever possible to prevent accidental overwriting of another code's variables or the same happening to yours.