You could also simplify the isCaster check a bit
Lua Code:
local cbCheck = function()
local _, playerClass = UnitClass('player')
local spec = GetSpecialization()
local isCaster = false
if(playerClass == 'DRUID' and (spec == 1 or spec == 4)) then
isCaster = true
elseif(playerClass == 'MONK' and spec == 2) then
isCaster = true
elseif(playerClass == 'PALADIN' and spec == 1) then
isCaster = true
elseif(playerClass == 'SHAMAN' and spec == 2) then
isCaster = true
elseif(playerClass == 'MAGE' or playerClass == 'PRIEST' or playerClass == 'WARLOCK') then
isCaster = true
end
end
Also, you need the events to delay the check, on init the spec is not available yet, and will return nil.