Script for UI count 2D

Hey everyone,

I was following this tutorial:

so I have a hero who collect coins.
and now I really would like to make a score count and game over text - which I did, via UI - text, but now I need to make it work with a script - I tried a few thinks but sadly nothing did work.

Has someone an idea? Probably not an hard question, but I just started using unity.

Until now I made a script GameController and wrote this:

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

public class GameController : MonoBehaviour {

public Text scoreText, gameOverText;
int playerScore = 0;

}

and linked my score and game over text to the game controller.

Hello! In the future, please click Insert > Code and paste your code in there so it looks like this:

Debug.Log("Hello world!");

Now, all you have to do to change your score count is:

scoreText.text = playerScore;

Make sure to update your score text every time the player’s score changes, and that scoreText is set in the editor!
For more info, here’s a link to Unity’s Text object: https://docs.unity3d.com/ScriptReference/UI.Text.html