Loading Scripts For Specific Template

is_page_template only works for templates belonging to the page post type. It appears your template is for a custom taxonomy, so you want to instead check if is_tax.

if( is_tax( 'tableofcontents' ) )

error code: 523