When dealing with system message scripts, it's good practice to be conscious of what scriptData is being set to. For example, in a ChallengeStartedMessage, calling Spark.setScriptData("key", "value") is setting scriptData on the message, not the Challenge itself.
To set scriptData to the actual Challenge, you'd need to use Spark.getChallenge(Spark.getData().challenge.challengeId).setScriptData("key", "value");
For more information, see our SparkChallenge documentation here.