Global variables are “global” within the file they were defined in. If you want to use them in another file, you need to pass their values, e.g. via script parameter or script result, or put them into a mutually accessible storage location, e.g. a global field.
Global variables are file specific, not solution specific. You need to pass the gloable variable to the second file using a script parameter.