When using
and I call it
where if I use

there is no error.
So for some reason when you use blocks to create a script and run it, it losses all global variables.
When using
So for some reason when you use blocks to create a script and run it, it losses all global variables.
This is not a bug, it's just how it's designed.
You see, each grey ring has a context, where it knows what script and sprite created the ring, as well as all the variables in the script. When you split or join by blocks, it loses it's context, so the script doesn't know what variables exist, this includes global variables.
You can fix this by binding the script to the currently running script, like this.