Slider Expression Error
Copy link to clipboard
Copied
So I was trying to create the countdown effect using the number slider effect. I saw instructions on how to do this on youtube, but when I followed their instructions, there was an error in the expression. Namely, the expression I typed was this...
slider = Math.round(effect("Slider Control")("Slider"))
sec = slider%60
min = Math.floor(slider/60)
function addZero(n){ if (n<10) return "0" + n else return n }
addZero(min) + ":" + addZero(sec)
And it said, "Invalid numeric result (divide by zero)" . Which was weird because it never said that when other youtubers typed the expression. Also, I even changed the settings from "JavaScript" to "Extended Script" but nothing is working. If you can help me out that would be great as this issue is driving me crazy.
Copy link to clipboard
Copied
Try this on the Javascript expression engine:
slider = Math.round(effect("Slider Control")("Slider"))
sec = slider%60
min = Math.floor(slider/60)
function addZero(n) {
if (n<10) {
return "0" + n;
} else {
return n;
}
}
addZero(min) + ":" + addZero(sec);
Copy link to clipboard
Copied
I had this same issue. For some reason all the tutorials I watched put the expression on the Slider Effect not the Source Text. After putting it on the Source Text it is fixed
Copy link to clipboard
Copied
Forgot to mention that there are missing semicolons after your slider, sec, and min variables, so make sure to add those at the end of these lines
Copy link to clipboard
Copied
It still shows an error for the first line of the expression saying "couldn't turn result into numeric value"
Copy link to clipboard
Copied
Same things for me!
Copy link to clipboard
Copied
Where are you applying the expression? You'll probably get that error if you apply the expression to anything other than the Source Text property of a text layer.
Copy link to clipboard
Copied
Yes turns out I was stupid all along, I put the expression in the slider effect rather than the source text area. That was the cause of the issue the entire time. When I looked closely, it even showed that on youtube. Thank you guys so much for trying to help.

