Perhaps the real problem here is how to create an instance of a
VisualScript. Note that
new does not really mean "you can access variables", it means a new instance of the script is being created. Each instance is independent from others.
When you use
new in GDScript, what it does is to create an instance of the class it extends from, and hen attach an instance of the script to it. This looks transparent from script usage, but that's what actually happens under the hood.
new doesn't seem to work with
VisualScript. So you'll have to use what's under the hood manually:
# If the script extends `Node`, create a new node.
# If it extends something else, change the class.
var node = Node.new()
# This creates an instance of the script
This works for me.
Also verify what class your VisualScript extends from. If it's a node, it must be added to the tree because otherwise it will leak when not freed manually.