Forum Discussion
JimCarry
Community Member
Feel free to try out the JavaScript code below. Additionally, create a new text variable named 'time' in Storyline, with a default value set to 15 minutes. Execute this script when the timeline starts. I hope you find this helpful!
var player = GetPlayer();
var sec = 900;
function startTimer(){
sec -= 1;
var minutes = Math.floor(sec / 60);
var seconds = sec % 60;
var timeString = minutes.toString().padStart(2, '0') + ":" + seconds.toString().padStart(2, '0');
player.SetVar("time", timeString);
if (sec < 0) {
clearInterval(timerId);
player.SetVar("time", "Time's Up");
}
}
var timerId = setInterval(startTimer, 1000);
EsmeraldaBar868
4 months agoCommunity Member
Thank you, Jim! I used this code and it worked! I really appreciate it.