auto-SetScale when logging script

I just added these commands

To this

and added the missing end