How to put score and what codes to use

Hi im a beginner in unity and would love to have some help,
I cannot see any tutorial regarding my game and i have no idea how to do this script and this is the last thing that i need.
I only need the script for 1 scene and i have finished the other and i need this for my thesis.

Ok so here it is,
I need an image that is moving from left to right using

 using UnityEngine;
 using System.Collections;
 
 public class BackAndForth : MonoBehaviour {
 
     public float delta = 100.0f;  // Amount to move left and right from the start point
     public float speed = 2.0f; 
     private Vector3 startPos;
 
     void Start () {
         startPos = transform.position;
     }
     
     void Update () {
         Vector3 v = startPos;
         v.x += delta * Mathf.Sin (Time.time * speed);
         transform.position = v;
     }
 }

My game is like a dart game that you need to click or shoot the target, the farther away the less score. But the difference is i’m using a princess as the target and the dart will be a kiss. Clicking will trigger the kiss and the target should be the lips. And also i don’t know how to put score in that but i have a scoring system from the other scene.
Here it is:
I got this from one of the tutorials from internet

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class ScoreManager1 : MonoBehaviour {

	public Text scoreText;
	public Text hiScoreText;

	public float scoreCount;
	public float hiScoreCount;

	public float pointsPerSecond;

	public bool scoreIncreasing;



	// Use this for initialization
	void Start () {
	

	}
	
	// Update is called once per frame
	void Update () {

		if (scoreIncreasing) {
			scoreCount -= pointsPerSecond * Time.deltaTime;
		}
		if (scoreCount > hiScoreCount) {
			hiScoreCount = scoreCount;
		}


		scoreText.text = "Score: " + Mathf.Round (scoreCount);
		hiScoreText.text = "High Score: " + Mathf.Round (hiScoreCount);
	}

}

I hope you guys can help me with this. Would really appreciate your help i’ve been stuck here for 1 month :frowning:

first delete all your player preference using playerpreferences.deleteall()…

after check your scripts is any scrite having PlayerPrefs.SetInt(“HighScores”,0) in start or awake methods. may this help to you…

you are running your highscore updation code in update try to avoid that thing.

PlayerPrefs is used for storing persistent data, like a high score, but not a score which is temporary. The difference being a score only gets used -while playing the game- the highscore gets saved so it can be looked at the next day or whenever. So you don’t need to use

PlayerPrefs.GetInt("Score");

just keep that as a variable in your script, the

int score;

Now one thing you need to understand is why you can’t do this:

public float scoreCount = PlayerPrefs.GetFloat ("Score");

You’re declaring a variable when you call public float like that, and it’s called initializing when you set it equal to something. That’s all you’re allowed to do at that point, before you get into any methods. After that you have your Start() method, inside of which you could call PlayerPrefs.GetFloat(“Score”); because that is a part of the script that gets executed, or run. The scoreCount is just a variable and only gets used because it’s not in a method, so you can’t called execution like GetFloat there.

How about something like this:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class MyClass : MonoBehaviour {

	float score = 0;
	Text scoreDisplay;
	Text highScoreDisplay;
	//you cannot call PlayerPrefs or any method here
	float currentHighScore;

	//declare initial values here
	void Start () {
		scoreDisplay = GameObject.Find("MainUI/ScoreDisplay").GetComponent<Text>();
		highScoreDisplay = GameObject.Find("MainUI/HighScoreDisplay").GetComponent<Text>();
		//call PlayerPrefs inside a method like Start();
		currentHighScore = PlayerPrefs.GetFloat("HighScore");
		highScoreDisplay.text = Mathf.RoundToInt(currentHighScore).ToString();
	}

	void AddToScore (int amount) {
		score += amount;
		//Call another method to do something for you
		UpdateScore();
	}

	void UpdateScore () {
		scoreDisplay.text = Mathf.RoundToInt(score).ToString();

		//don't update the highscore when you don't need to
		if (score > currentHighScore) {
			PlayerPrefs.SetFloat("HighScore", score);
			//try to call outside methods as little as possible by storing and reusing
			currentHighScore = score;
			highScoreDisplay.text = Mathf.RoundToInt(currentHighScore).ToString();
		}
	}
	
}

There are tons of different ways to do anything you can imagine. This is how I might get started writing something along these lines.