2 PlayerPrefs settings with the same code, one saves and loads as intended, the other does not

Hello,
I am having problems with saving and loading settings for my game. I’ve already done volume and sensitivity settings. I can save and load volume settings without any issues, but when I change the sensitivity and reload the scene it resets to its default value, even though the code for both settings is exactly the same (last time I checked). Here’s the script: using System.Collections;using System.Collections.Generic;using UnityEngine; - Pastebin.com

Less than half of the work coding is writing code, the majority is debugging and figuring out why things don’t work the way you expect them. The likelihood of a basic Unity API failing is very small, it’s much more likely that you’re doing something wrong or the API doesn’t behave as you expect it to. The only way is to debug your code step by step to figure out where things go wrong.

In your script, I suggest printing out whenever you get and set a PlayerPrefs value. Then you can check in the console what exactly you save and load, in which order, and if the values are what you expect. Then check the stacks of the log messages to figure out why PlayerPrefs might be called in unexpected places.

As a hint: Your Save method is called before the sensitivity is loaded, overwriting the saved value with whatever the slider is set to at the beginning. You’ll need to refactor your script to prevent this from happening.