Explanation

A variable is declared as persistent in this script. However, variables can be declared as persistent in functions only. In scripts, there is no function workspace in which the variable can persist.


Suggested Action

Rewrite the script as a function or use a class property that persists naturally. If that is not possible, you can declare the variable as global instead. However, be aware that the use of global is discouraged because programs that use it can be harder to maintain, extend, and use with other programs.