Loadlevel isn't working.

Could someone help me with my script?
I made a score script. When the score = 1, the scene will be reloaded.
But when the score = 3, it needs to load a other level.
Right now it will always load the same scene.

This is my script so far.

#pragma strict

static var currentScore : int = 0;
var test = 0; 

function Start () {
currentScore = 0;

function Update () {
 test = currentScore;

function OnTriggerEnter (col : Collider) {
if(col.gameObject.name == "Cylinder" || test == 3){
if(col.gameObject.name == "Cylinder" || test == 1){

The issue is most likely arising because you are using a short circuit “OR” operator whilst comparing the same string. A short circuit OR will evaluate the first condition and if it is true it will execute the code block and completely ignore the other conditional.
Now, because you are asking the compiler to compare the collider’s name first it will become true and ignore the test conditional and because you are comparing the same string twice the compiler will be picking both of the statements but one will execute before the other. To fix this issue you’ll most likely want to use the && (and) operator and make use of else if instead. For example:

		if(gameObject.name == "Cylinder" && Test == 3)
		else if(gameObject.name == "Cylinder" && Test == 1)

This will now compare both the collider’s name and the Test score, before executing the code block. I hope this helped. :slight_smile: