Carrying Scripts Over

I am sorta new at unity, but i want to make a game that is sort of like an rpg. And for what i want for an rpg, you need like base stats, like levels, health, attack dmg, so on. So, my question is, how do you carry scripts so that they are always there or so that there is the same exact script in 2 scenes, instead of putting the script back into an object when you make a new scene. In other words, is there any way to make a base script that is always there and i can take an instance of that script at any time in any scene?

I don´t really understand what you mean, but isn´t it enough for you to just add the scripts to your character?

To “carry” scripts over from one scene to another you can do this at the Start or Awake method in your script:

DontDestroyOnLoad(this);

This will will not destroy the script nor the gameobject containing the script thus enabling you to keep giving it data throughout your game. This is commonly used when implementing a singleton pattern like a GameManager.

Yea, not destroying a script is probly what i need. For more clarification, is there an exact script that i can have to be carried over? For example. I have a person at lvl 1 in scene one. Then as i progress through the game, the person lvls up. Is there any way to keep that script going trhough scene through scene, but still have a particle instance of the script, so when i go to a certain scene, i can be either lvl 20 or lvl 50 depending on how i played the game?

Welcome to the forum, Pto345!

Are you saying you want to save game states as you go through the game? For example, so you can restore an earlier state when the character dies?

That is not exactly what i am asking. I am asking if there are ways to have a baseline script for some character. That script is always in the game because it tells the lvl of the character, the health, so on and so forth. When i go from scene 1 to scene 3, or dungeon 1 to dungeon 3, i want to have that same script with the same exact numbers.

This is really hard to explain. I just need the same exact script during the whole game. That script can change when the cahracter lvls up, but it still needs to be the same exact script. Not one i drag on drop on a character every time create a scene. Do you understand what i mean?

If you need to save data temporarily, you can use normal scripts/components, whose role is to hold variables.

If you need to save data permanently, that’s another problem, which I haven’t met yet, and I don’t have a good answer. :? Some kind of .txt manipulation, probably.