Changing the type of a variable

Here’s my question:

I have a variable stands for 1 script,
but I want to be able to change the type of the variable so that it won’t be
a variable for script1 but for script2 if something happened.

(answer with c# please)

Make the same type of variable in script 2, access script 1 in script 2, replace script 2 with 1s value / data and its stored. You can also send it to script 2 from 1 if you want it to happen at a certain point. Depends how when and why you want to back it up or duplicate it. Look into GetComponent to accomplish this type of thing, or acess th script directly in code…

First off, a variable doesn’t access a script, a script accesses a variable.

Secondly, you cannot change the type of a variable without messing it all up (it’s not like you can turn a string into a double and assume everything will work, for example).

With the pre-pre-pre-basics of programming behind us, we will now go on to very serious programming:

To access a variable in another script, make them public and static. Like this:

public static int someVariable = 9000;

This variable exists in script1.cs. Now the really hard stuff comes! In script2.cs, type this:

script1.someVariable;