Not tested but based on that error you could try:
Code:
--[Change Raid Frame OOR Fade/Alpha Transparency]
hooksecurefunc("CompactUnitFrame_UpdateInRange", function(frame)
local inRange, checkedRange = UnitInRange(frame.displayedUnit)
local alpha = checkedRange and not inRange and 0.3 or 1
frame:SetAlpha(alpha)
if frame.background then
frame.background:SetAlpha(alpha)
end
end)