# How can I add different amount of stars depending on points reached?

Hello, so I am creating a game that rewards a star when a certain score is reached. If the player reached 15 points he gets 1 star and when the score increases to 50 points he gets another 2 stars and when he reached 70 points he gets another 3 (so 5 stars will be added to his current stars). And then the stars he collected will be saved. Please help me how can I implements that scenario I have tried some codes but doesn’t work well.

Here is my current code:

if (Score == 15)
{

``````        starAmount += 1;
starC.text = starAmount.ToString();
}
if (Score == 50)
{
starAmount += 2;
starC.text = starAmount.ToString();
}
if (Score == 70)
{
starAmount += 3;
starC.text = starAmount.ToString();
}

if (starAmount > PlayerPrefs.GetFloat("stars", 0))
{
PlayerPrefs.SetFloat("stars", starAmount);
starC.text = starAmount.ToString();
}
``````

I believe you should use `less or equal` comparison with `else if` instead of `equal` comparisons.

``````if (Score < 15 )
starAmount = 0;
else if (Score < 50)
starAmount = 1;
else if (Score < 70)
starAmount = 2;
else
starAmount = 3;

if (starAmount > PlayerPrefs.GetFloat("stars", 0))
PlayerPrefs.SetFloat("stars", starAmount);
starC.text = starAmount.ToString();
``````

Using an array would be even better:

``````int[] starsGainThresholds = new int[]{ 15, 50, 70 } ; // You can even put this as a public class member if you want to edit it in the editor

for( int thresholdIndex = 0 ; thresholdIndex < starsGainThresholds.Length ; ++thresholdIndex )
{
if( Score >= starsGainThresholds[thresholdIndex] )
starAmount++ ;
}
if (starAmount > PlayerPrefs.GetFloat("stars", 0))
{
PlayerPrefs.SetFloat("stars", starAmount);
}
starC.text = starAmount.ToString();
``````