Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
1

Slider Expression Error

Community Beginner ,
Nov 23, 2023 Nov 23, 2023

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. 

TOPICS
Expressions
770
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 23, 2023 Nov 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);

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 22, 2024 Aug 22, 2024
LATEST

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 23, 2023 Nov 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 23, 2023 Nov 23, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 22, 2024 Aug 22, 2024

Same things for me!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 23, 2023 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 23, 2023 Nov 23, 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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines