Checkpoint Problems

Hi All,

Me and a friend was working on a script for my 2D platformer that has plenty of levels, i needed a checkpoint at level 25 so we got that working but im having problems adding another checkpoint for another level, please see script below, i was told to add the second if function inside the current, this is what i have but the second checkpoint is not working, any ideas peeps?

The second CP is level 26 for testing :).

**public class OnGUI2D : MonoBehaviour
{

public void ChangeScene(string sceneName)
{
	if (PlayerPrefs.GetInt("Checkpoint", 0)==1)
	{
		LevelManager.instance.Score = 39560;
		Application.LoadLevel(25);
	}
    else
		if (PlayerPrefs.GetInt("Checkpoint", 0)==1)
	{
		LevelManager.instance.Score = 42440;
		Application.LoadLevel(26);
	}

else

	{
		Application.LoadLevel(sceneName);
	}
}**

The code will never get to the 2nd “else if” because the conditions for both the first and second if are exactly the same.

So, you’re saying that if the stored value of the “Checkpoint” value is “1”, to do the first if. The only way you’ll ever get to the “else if” is when the first if’s expression is false. However, if it’s false for the first if, it’ll be false for the second if also. So, you’ll always execute either 1) the first if block or 2) neither of the if blocks…

Surely, the condition for the 2nd checkpoint should be different…