The problem:
Anytime I cast a spell that should be "caught" by a "HasKeyword" if statement, it simply passes through and moves on.
Spells with "Ritual Spell Effect" keywords will sometimes be caught(the magic effect), but upon triggering again (the same magic effect) will be false. I have no idea why it only sometimes registers the keyword. I have confirmed everything is working EXCEPT those "HasKeyword" statements and have no idea what I'm doing wrong.
-Yes I've properly assigned all my properties(before you ask

Below is the code that attaches dynamically to actors and attempts(unsuccessfully) to weed out "Cloak" and "Ritual" Spells. Please let me know what I'm doing wrong(I'm sure it's something silly but I've been struggling with this for 20+ hours now)
Spoiler
Scriptname AerSpellSneakMessageDisplay extends ReferenceAlias{Shows the message in the upper left hand corner}Perk Property DBBackstab AutoPerk Property AerSneakSpellPerk AutoKeyword Property MagicCloak AutoKeyword Property RitualSpellEffect AutoKeyword Property AerDoNotMessageDisplay AutoMessage Property AerSpellSneakMsg AutoMessage Property AerSpellSneakDBMsg Autobool Function HasKeyword(Keyword akKeyword) nativeint counter = 0Event OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect) ;If the source of damage if from the player if(akCaster == Game.GetPlayer()) debug.MessageBox((akEffect as Form).HasKeyword(AerDoNotMessageDisplay)) ;Check if spell is a cloak (Cant sneak attack - target self) if(((akEffect as Form).HasKeyword(MagicCloak)) == False) ;Check if spell is a Ritual effect (Cant sneak attack - 2 handed) if(((akEffect as Form).HasKeyword(RitualSpellEffect)) == False) ;Check if spell has any extra affects that mess up display of messages and grant extra experience if(((akEffect as Form).HasKeyword(AerDoNotMessageDisplay)) == False) ;As long as the play is not in combat (aka unseen) if (GetActorReference().GetCombatState() != 1) ;If the spell being cast is from the Destruction school if((akEffect as MagicEffect).GetAssociatedSkill() == "Destruction" ) ;As long as sneaking if (Game.GetPlayer().IsSneaking() == 1) ;Check Which Message to display/can spell sneak attack if (Game.GetPlayer().HasPerk(AerSneakSpellPerk)==1) ;Default Spell Sneak Perk ;Grant some sneak experience Game.AdvanceSkill("Sneak", 6) ;If Player has both perks - Apply Backstab perk 2.25x if (Game.GetPlayer().HasPerk(DBBackstab)==1) ;Grant bonus experience if using backstab gloves Game.AdvanceSkill("Sneak", 2) AerSpellSneakDBMsg.Show() ;2.25x Message else ;He only has the default sneak attack - No backstab perk AerSpellSneakMsg.Show() ;1.5x MessageendifendifendifendifendifendifendifendifendifEndEvent