Im trying to get a point counter but my points wont go up.

I have searched the fourms for hours so can somone provide me with a JS Script where each time i kill an enemy the GUItext that says points goes up. Thankyou in advance.

Although I’m very much a beginner myself I believe I know how to achieve what you are looking for or at the very least pretty close. Not in JavaScript but C# although I’m sure it cant be too difficult to translate it over.

Enemy Behavior: Attach this script to your enemy

public class EnemyBehavior : MonoBehaviour {
    	void OnTriggerEnter(Collider collider)
    	{
    		switch(collider.gameObject.name)
    		{
    		case "Player":
    			EnemyController.enemyCount++;
    			Destroy (this.gameObject);
    			break;	
    		}
    	}
    }

EnemyController: Attach this script inside an empty game object.

public class EnemyController : MonoBehaviour {
	
	public static int enemyCount = 0;
	
	
	void OnGUI()
	{
		string enemyText = "Points: " + enemyCount;
		
		GUI.Box (new Rect(Screen.width - 150, 20, 130, 20), enemyText);
		
		
	}
	
}