Point counter = 0 if change level ... HOW ?

Hello. I have a very simple question. I have a game with 2 maps. On the 2 maps you can destroy objects with a gun … but when I change the map I want to have again 0 Kills on the Point Counter. Now if I change the level the kills remain saved. How can I make that if I change level Point Count = 0 ?

Here are my scripts:

using UnityEngine;
using System.Collections;

public class PointCounter : MonoBehaviour {
    public GUISkin guiSkin = null;
    public static int points = 0;
	
    void OnGUI()
    {
        GUI.skin = guiSkin;
        GUI.Label(new Rect(317.0f, 78.5f, 400.0f, 120.0f), points.ToString());
        GUI.skin = null;
    }
	void Awake() {
        DontDestroyOnLoad(transform.gameObject);
    }
}

and the 2nd script is:

using UnityEngine; using
System.Collections;

public class Zombie : MonoBehaviour {

public int points = 1; // You can edit this in the inspector

void OnDestroy()
{
    PointCounter.points += points;
} 	void OnDontDestroy()
{
    PointCounter.points -= points;
} 	void Awake() {
    DontDestroyOnLoad(transform.gameObject);
} }

I NEED VERY FAST HELP! Thank you in advance for every answer :slight_smile:

It’s in the nature of static vars that it won’t reset, but I’ll save that speech for another time. The easiest way is just to reset it as soon as the object loads.

using UnityEngine;
using System.Collections;

public class PointCounter : MonoBehaviour {
public GUISkin guiSkin = null;
public static int points = 0;

void OnGUI()
{
    GUI.skin = guiSkin;
    GUI.Label(new Rect(317.0f, 78.5f, 400.0f, 120.0f), points.ToString());
    GUI.skin = null;
}
void Awake() {
    DontDestroyOnLoad(transform.gameObject);
    //--New Stuff---
    points = 0;
    //-------------
}

}

if(Application.Loadlevel(1))
{
Points = 0;
}

that may work