Help setting high score for different levels.

public void OnDeath()
{
isDead = true;
if(PlayerPrefs.GetFloat(“Highscore1motomadness”) < score)
PlayerPrefs.SetFloat(“Highscore1motomadness”, score);

isDead = true;
if (PlayerPrefs.GetFloat(“Highscore2Desert”) < score)
PlayerPrefs.SetFloat(“Highscore2Desert”, score);

deathMenu.ToggleEndMenu(score);
}

I’m not sure how to set the isDead to a specific scene when I get a high score in moto madness it also sets it in desert

You need to either have a way to know what scene the player was playing on, so you can do something like:

public void OnDeath()
{
   // guessing you use the isDead boolean somewhere else, otherwise it's unnecessary here.
   isDead = true;
  
   if (PlayerPrefs.GetFloat("ActiveScene") == "Motomadness")
   {
      if(PlayerPrefs.GetFloat("Highscore1motomadness") < score)
          PlayerPrefs.SetFloat("Highscore1motomadness", score);
   }

   if (PlayerPrefs.GetFloat("ActiveScene") == "Desert")
   {
       if (PlayerPrefs.GetFloat("Highscore2Desert") < score)
           PlayerPrefs.SetFloat("Highscore2Desert", score);
   }

   deathMenu.ToggleEndMenu(score);
}

or… you need to implement a specific isDead boolean per scene. So isDeadInMotoMadness and isDeadInDesert etc. I suggest you go with the first though. So when a player plays a specific scene set the “ActiveScene” to that scene and go from there.

I applied what you said and got this error “Assets/Scripts/Score.cs(64,25): error CS0019: Operator ==' cannot be applied to operands of type float’ and `string’.”

It’s because in my bit of mockup code I’m using GetFloat(“ActiveScene”) … which will probably return nothing, since I made up the variable with the string “Motomadness”. It’s still early morning.
You will need to implement the “ActiveScene” bit yourself, like you did with “highscore1motomadness” and “HIghscore2Desert”.

My aim was to give you an idea on how to fix it, not a copy-paste solution.

using System.Collections;
using System.Collections.Generic;
using System.Net;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class Score : MonoBehaviour
{
    private float score = 0.0f;
    public float scene1 = "motomadness";

    private int difficultyLevel = 1;
    private int maxDifficultyLevel = 10;
    private int scoreToNextLevel = 10;

    private bool isDead = false;

    public Text scoreText;
    public DeathMenu deathMenu;

    // Start is called before the first frame update
    void Start()
    {
        PlayerPrefs.SetFloat("Highscore1motomadness", score); //For scene 1
        PlayerPrefs.SetFloat("Highscore2Desert", score); //For scene 2
        PlayerPrefs.SetFloat("ActiveScene", scene1);
    }

    // Update is called once per frame
    void Update()
    {
        if (isDead)
            return;

        if (score >= scoreToNextLevel)
            LevelUp();

        score += Time.deltaTime * difficultyLevel;
        scoreText.text = ((int)score).ToString ();
       
    }

    void LevelUp()
    {
        if (difficultyLevel == maxDifficultyLevel)
            return;

        scoreToNextLevel *= 2;
        difficultyLevel++;

        GetComponent<playermotor>().SetSpeed(difficultyLevel);
    }

    public void OnDeath()
    {
        isDead = true;

        if (PlayerPrefs.GetFloat("ActiveScene") == "motomadness")
        {
            if (PlayerPrefs.GetFloat("Highscore1motomadness") < score)
                PlayerPrefs.SetFloat("Highscore1motomadness", score);
        }

        if (PlayerPrefs.GetFloat("ActiveScene") == "Desert")
        {
            if (PlayerPrefs.GetFloat("Highscore2Desert") < score)
                PlayerPrefs.SetFloat("Highscore2Desert", score);
        }


        deathMenu.ToggleEndMenu(score);
    }

}

[ICODE][ICODE][ICODE][/ICODE][/ICODE][/ICODE]

this is the full score code I tried messing with it to get it to work but I still get that error and an error for the setfloat ActiveScene line which i tried to fix using the public float scene1 = motomadness and i get this error as well as the other two: Assets/Scripts/Score.cs(12,27): error CS0029: Cannot implicitly convert type string' to float’.

Change the string to a number, or use PlayerPrefs.SetString

sorry I’m new to this, I changed the string to a number and it cleared the last error but I still have the == error.