OnLevelWasLoaded script problem.

Hello. I am making a game that is 2D and for Android. I am having a problem where my score won’t completely transfer through a scene ( Using don’tdestroyonload doesn’t fix it ) The script I use only updates the score when a point is awarded. So I went through some looking and found OnLevelWasLoaded. How can I use OnLevelWasLoaded to update the score/text by basically adding no points ( For example; adding 0 points, which I hope updates the text to display the score )

The scoremanager script is

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ScoreManager : MonoBehaviour
{
	public static int score; // The player's score.
	Text text; // Reference to the Text component.
	
	void Awake ()
	{
		text = GetComponent <Text> ();
	}
	
	public void SetScore (int newScore)
	{
		ScoreManager.score = newScore; //update the static score variable
		text.text = "Score: " + score;
		Debug.Log;
	}
}

The script that adds points is

using UnityEngine;
using System.Collections;

public class Score : MonoBehaviour {
	public int scoreValue = 1;
	public ScoreManager scoreManager;
	

	
	void OnMouseDown () {
		scoreManager.SetScore(ScoreManager.score + scoreValue);
	}
}

and I want to use

function OnLevelWasLoaded (level : int) {
		if (level == 13) {
			print ("Woohoo");
		}
	}

I want to use that ^^^^ by somehow converting it to add no points ( Which I’ll repeat that I hope will update the text )

The reason I am posting this is because I do not know how to convert it at all, I am extremely new to scripting and game creating.

I have tried doing it and I will show what I have done

using UnityEngine;
using System.Collections;

public class aed : MonoBehaviour {
	public int scoreValue = 1;
	public ScoreManager scoreManager;
	
	
	void  OnLevelWasLoaded ( int level  ){
		if (level = "EndGame") {
			scoreManager.SetScore(ScoreManager.score + scoreValue);
		}
	}
}

I do not know if this would even work but there is an error saying

Assets/Standard Assets (Mobile)/Textures/aed.cs(10,21): error CS0029: Cannot implicitly convert type string' to int’

I have no clue how to fix that which is why I am posting this.

First, your variable level is type integer and you are comparing it to a string. That can’t happen. You could choose what to do from these two:

if (level == 1) // for example, replace the 1 by the number of the level

Don’t forget the double equals to compare things. This way you are comparing the integer level to an integer, which is what you should do. Or, you could change the type of the variable.

void OnLevelWasLoaded (string level)
{
    if (level == "EndGame") 
    {
        scoreManager.SetScore(ScoreManager.score + scoreValue);
    }
}

Hope this helps.