Skip to main content
Participant
November 23, 2023
Question

Slider Expression Error

  • November 23, 2023
  • 5 replies
  • 1466 views

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. 

5 replies

Participant
November 24, 2023

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. 

Dan Ebberts
Community Expert
Community Expert
November 23, 2023

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.

Participant
November 23, 2023

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

Participant
August 22, 2024

Same things for me!

Robert Zinke
Participating Frequently
November 23, 2023

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

Robert Zinke
Participating Frequently
November 23, 2023

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

 

Participant
August 22, 2024

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