Variables cleaning after scene reload

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Azirov

I have a global singleton script, where i keep my Health variable. I acess this variable from another script inside this scene. After i use get_tree().reload_current_scene(), my Health variable in the second script still have the same value like it was before scene reloading despite any further checks and changes in it. Why? How can i refresh all my variables after
get_tree().reload_current_scene()?

:bust_in_silhouette: Reply From: Gerardo Gonzalez

Singleton is a persistent way to save values between scenes, so you need reset all your values before you call get_tree().reload_current_scene() and that’s all