PlayerPrefs Problem

So i have everything set up and it works but i’m getting a problem since even though it says that pointspersec=1; after I put the PlayerPrefs it becomes 0 ingame. Here’s the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Click : MonoBehaviour {

public UnityEngine.UI.Text ppc;
public UnityEngine.UI.Text pointsDisplay;
public float points = 0;
public float pointsperclick = 1;

public void Start()
{
    points = PlayerPrefs.GetFloat("points1");
    pointsperclick = PlayerPrefs.GetFloat("points");
}

private void Update()
{
    pointsDisplay.text = "Points: " + CurrencyConverter.Instance.GetCurrencyIntoString(points, false, false);
    ppc.text = "Points / Click: " + CurrencyConverter.Instance.GetCurrencyIntoString(pointsperclick, false, true);

    PlayerPrefs.GetFloat("points1", points);
}

public void Clicked()
{
    points += pointsperclick;

    PlayerPrefs.SetFloat("points", pointsperclick);
}

}

If you want to have the pointsperclick you assigned in the script, use PlayerPrefs.SetFloat("points", pointsperclick); in Start().

Right now you are using pointsperclick = PlayerPrefs.GetFloat("points"); in Start(), which loads the “points” value to pointsperclick (which is most likely 0).

I also assumed that you wanted to save the points, not the points per click in Clicked().

So the complete script should look like:

public class Click : MonoBehaviour {

 public UnityEngine.UI.Text ppc;
 public UnityEngine.UI.Text pointsDisplay;
 public float points = 0;
 public float pointsperclick = 1;
 public void Start()
 {
     points = PlayerPrefs.GetFloat("points1");
     PlayerPrefs.SetFloat("points", pointsperclick);
 }
 private void Update()
 {
     pointsDisplay.text = "Points: " + CurrencyConverter.Instance.GetCurrencyIntoString(points, false, false);
     ppc.text = "Points / Click: " + CurrencyConverter.Instance.GetCurrencyIntoString(pointsperclick, false, true);
 }
 public void Clicked()
 {
     points += pointsperclick;
     PlayerPrefs.SetFloat("points1", points);
 }