I get an error that goes like this:
Cannot implicitly convert type ‘string’ to ‘UnityEngine.UI.Text’
This is my code:
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehaviour
{
public Transform player;
public Text scoreText;
// Update is called once per frame
void Update()
{
scoreText = player.position.z.ToString(“0”);
}
}
Can anybody tell me what is wrong with it?
You need change
scoreText = player.position.z.ToString("0");
to
scoreText.text = player.position.z.ToString("0");
And please edit subject topic to more informative.
Also, please use Code Tags
** Using code tags properly **
Learning to use documentation will be your next step. You will save tons of time, rather than waiting on the forum for the answer.
https://docs.unity3d.com/ScriptReference/UI.Text-text.html
Sorry, I am new to unity, thanks!