I have looked through some sample scripts and come up with this so far.
Scriptname LeftPawAlightsunspell
Event OnCombatStateChanged(Actor akTarget, int aeCombatState)
EndEvent
if (akTarget == Game.GetActor().HasKeyword(ActorTypeUndead)
AddSpell(DLCSunSpell)
ElseIf (aeCombatState == 0)
RemoveSpell(DLCSunSpell)
EndIf
EndIf
EndFunction
But I get a compile error saying line 6,0 EOF at if is wrong. This is my first foray into scripting and the script is supposed to add the spell to a custom follower I am making and then remove it when combat is finished. This is to stop them from using the spell on living targets. Any help would be appreciated.