Sorry to bring up this old post. But I have very similar problem.
After setting up FSM Template with exposed variable, and run FSM. The error log of "InvalidCastException: Specified cast is not valid." keep appear. And other game mechanism go wrongs as well.
I have already spent hours to troubleshoot it but in vain.
Roll back to a earlier version doesn't help either.
Could anyone point me in the right direction, on how to solve it? Or at least what goes wrong?
My unity version is 2019.1.14f1
My playmaker version is 1.9.0.p19
InvalidCastException: Specified cast is not valid.
HutongGames.PlayMaker.FsmVar.ApplyValueTo (HutongGames.PlayMaker.INamedVariable targetVariable) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmVariables/FsmVar.cs:674)
HutongGames.PlayMaker.FsmVarOverride.Apply (HutongGames.PlayMaker.FsmVariables variables) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmVarOverride.cs:33)
HutongGames.PlayMaker.FsmTemplateControl.ApplyOverrides (HutongGames.PlayMaker.Fsm overrideFsm) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmTemplateControl.cs:133)
HutongGames.PlayMaker.FsmTemplateControl.InstantiateFsm () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmTemplateControl.cs:73)
HutongGames.PlayMaker.Fsm.CreateSubFsm (HutongGames.PlayMaker.FsmTemplateControl templateControl) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1460)
HutongGames.PlayMaker.Actions.RunFSM.Awake () (at Assets/PlayMaker/Actions/StateMachine/RunFSM.cs:33)
HutongGames.PlayMaker.Fsm.Awake () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1650)
HutongGames.PlayMaker.Fsm.Init (UnityEngine.MonoBehaviour component) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1677)
PlayMakerFSM.Init () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:255)
PlayMakerFSM.Awake () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:210)