how to pass boolean variable into another scene without destroy it properties

hi guys, i want to pass a boolean variable from a scene into another scene. when am trying to load into previous scene the properties for the variables are destroying?

how can i avoid this?

i have already used DontDestroyOnLoad(this); but its not seems good...

is this any chance to pass variables with DontDestroyOnLoad function....?

can any one help me?

Use DontDestroyOnLoad(gameObject); to keep the GameObject the script is on alive

Alternatively, you could make the boolean value static, so it persists no matter whether the script is destroyed or not, but that'll stop you from being able to assign to it in the inspector