If its undefined I think it means that the variable isnt set to anything. Have you double checked that your variable name is correct, and if this Javascript triggers AFTER the variable is set in storyline?
I don't know if this is the reason but maybe splitting the code onto different lines might help. I don't see why this would be the case, but perhaps all of that happening in one line is causing an issue. So something like this might work?
var player = GetPlayer();
var score = player.GetVar("UserTOTAL");
parent.RecordScore(score);
I'm not sure why else you might be getting 'undefined', It usually means that the variable doesn't have a value set to it. So if it definitely has a value, and is the correct name, then I'm not sure why exactly it is not working...
4 Replies
If its undefined I think it means that the variable isnt set to anything. Have you double checked that your variable name is correct, and if this Javascript triggers AFTER the variable is set in storyline?
Thanks for reply Jackson. Yes, I have double checked the variable name and its correct and it is set prior to the Javascript trigger.
I wonder if I need to reformat the script??
I don't know if this is the reason but maybe splitting the code onto different lines might help. I don't see why this would be the case, but perhaps all of that happening in one line is causing an issue. So something like this might work?
I'm not sure why else you might be getting 'undefined', It usually means that the variable doesn't have a value set to it. So if it definitely has a value, and is the correct name, then I'm not sure why exactly it is not working...
Here is some more information about "Undefined" - https://javascriptweblog.wordpress.com/2010/08/16/understanding-undefined-and-preventing-referenceerrors/
I hope you get it working! I'd love to hear the solution when its fixed.
Many thanks Jackson - I will give the new formatting a go and let you know.
This discussion is closed. You can start a new discussion or contact Articulate Support.