First, this is not a real problem. It is easy to make working script.
I made a button with "Single Step" action
Export Field Contents [ PDF::pdf [Let ( $path = Get(TemporaryPath) & Get(UUID) & ".PDF" ; 1 )];"$path"; Automatically Open ]
This set $path variable in field repetition calculation, then use it in same step.
Once close the file, then button not works only first time clicked, saying
“$path” could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk.
2nd click and after, this error not occurred.
It seems the variable is not set on first time, but the variable is local then vanish after button action completed, so there should be no difference in 1st and 2nd clicks. I can't see $path value before 2nd click.
"convert to script" change the behavior as "never work".