Where exactly do you get the error message, on script compiling?
Yes, while compiling.
Can you write down the exact error message?

Do you have the variables declared before the function like in your post (maybe you have two save_settings() functions in your script)?
Yes, it is. I have only one function. Btw., everytime I comment out the line that uses the variable, it tells me that another one is undeclared identifier. And then I comment it out, then it tells me that the panel itself (that was actually defined before the function too) is undeclared. I re-installed 3DGS ,but the problem persists. I have A8 v8.10.3 btw.