You should try to turn on SCORM debugging (https://docs.moodle.org/38/en/SCORM_FAQ#Debugging) and see what the logs say there. It should hopefully give you some clues as to what might be going wrong when. For example maybe your code works but is then over-ridden by Storyline later on?
You also might have more success with getting help in the Articulate forums for Storyline. Since it works the same way in SCORM Cloud, it doesn't sound like a Moodle specific issue.
You also might have more success with getting help in the Articulate forums for Storyline. Since it works the same way in SCORM Cloud, it doesn't sound like a Moodle specific issue.