Skip to main content
Participant
Nov 23, 2023 11:40 AM UTC
Question

Slider Expression Error

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. 

7 replies

Participant
Nov 24, 2023 4:48 AM UTC

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. 

Translate
Dan Ebberts
Community Expert
Community Expert
Nov 23, 2023 9:12 PM UTC

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.

Translate
Participant
Nov 23, 2023 8:43 PM UTC

It still shows an error for the first line of the expression saying "couldn't turn result into numeric value"

Translate
Participant
Aug 22, 2024 2:15 PM UTC

Same things for me!

Translate
Robert Zinke
Participating Frequently
Nov 23, 2023 12:24 PM UTC

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

Translate
Robert Zinke
Participating Frequently
Nov 23, 2023 12:22 PM UTC

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);

 

Translate
Participant
Aug 22, 2024 2:18 PM UTC

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

Translate