increase lives person 100 points

I made a space shooter game and I have lives and a scoring system. Now when the player hits 100 points the lives should increase by 2 but this also should happen for every 100 points the player hits.

I did try this

	public int additionLives = 2;

	public float targetScore = 100;

	if (score >= targetScore) {
			// Do something
			targetScore += 100;
			lives += additionLives;
			Debug.Log("You get more lives");

		}

my issue is it displays the msg in the log but don’t add the lives but then it don’t do anything else.

Any help would be great.

Where did you put the if statement? Shouldn’t it be inside of void Update()?

That way, it’ll always detect when the player can get more lives or not.

I would make a extra " score counter " that gets +1 everytime you get a point but you reset it when it reaches 100 in the " if(scoreLives >= targetScore) statement keep this seperated from you actually score and only use it for gaining your extra lives.

Maybe it is updating “lives” variable but you are not using the “lives” variable correctly. You need to post complete code to make the scenario more clear.

Maybe try

while (score >= targetScore)

instead of

if  (score >= targetScore)

So when the player gets lot of score it will give him lives for every 100