Converting problem

Hi!
I am trying to give stars by time passed. I can’t really explain so I’ll let the code do it for me
What do I do to make it work?
“stars_number” is an int equal to 10, it’s how many seconds before it reduces by 1 star.
I want the script to check if the player completed the level under(or equal to) 10 seconds.
I get that you can’t compare an int to a string, but I can’t convert the string to int (or int to string)

	int invoke_count;
	string time_played;

public void Show_score(int stars_number)
		{
		
		time_played = Time.timeSinceLevelLoad.ToString();
		
		if (stars_number <= time_played)
		{
			stars_number = 3;
		}
}

Time.timeSinceLevelLoaded returns a float value, just don’t convert it to a string, change your time_played variable to a float, and then do your comparison.

time_played = Time.timeSinceLevelLoad;

Also, int to string comparisons (or vise versa) are possible. If you need the time_played variable to be a string value, then you can use Single.Parse(time_played) to convert the string representation for your comparison.

if(starts_number <= Single.Parse(time_played))
{
   // Do stuff.
}