When you run your Lua code (in "dev... tools"), it works ? try to add a print in you code to debug it, like that :
for i=1,40 do
local name, rank, icon, count, debuffAuraType = UnitAura("player", i);
if debuffAuraType == "Magic" then
anyCurse = true;
print("true")
return;
end
end
print("false")