Keeping points tallied

Hey all!

I’m currently working on an arcade style game where you fire spheres at targets to gain points. Something is not quite right with part of my code, though. Whenever the player character fires at another object, the score resets instead of adding onto itself.

I’m still pretty bad with programming and sort of threw this together with help from a friend:


import UnityEngine.UI;

var ScoreManager : Text;
var score : int = 0;


function OnCollisionEnter (col : Collision){
    if(col.gameObject.tag == "Bullet"); {
 		score += 0;
    	ScoreManager.text = score.ToString();

What exactly am I missing? Thank you for your time!

Your score is not resetting but staying the same as you are adding 0 to your existing code at

score += 0;

Instead of 0 you need to add the amount of score you want to add after player fires another object. Something like in code below it is adding 10 points:

score += 10;