Death Counter dont work when changing scenes

Hello my death counter doesn’t work when i’m changing scenes, i have done void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
on my death counter script but it just starts with 0 when im changing scenes.

Set the count variable to static to keep it consistent across all scenes.
i.e.

    public static int deathCount;

The value will never be reset unless you reset it manually or you restart the exe.

Use PlayerPrefs, when you die use this:

     PlayerPrefs.SetInt ("deathCount", PlayerPrefs.GetInt("deathCount") + 1);

and when changing scene call:

     PlayerPrefs.GetInt("deathCount");