wp_enqueue has a resource but doesn’t generate a script tag [duplicate]

Your code is correct, but you will not see this <script> tag in your header!

The last parameter of wp_enqueue_script() is a flag regarding whether or not to load the script at the bottom of the page. You have this set to true, so you’re telling WordPress to create a <script> tag at the bottom of your HTML source, not in the <head> element.

Also, as mentioned in the comments, you should not be using the template_redirect hook for this. Use add_action( 'wp_enqueue_scripts', 'add_my_script' ); instead.