I am trying to display the Score of my player. I set up the reference to the Playermovement Script where the Scorecounting takes place and I converted the Score to a string type. I thought it would work like this but im getting the following error :
Assets/ScoreDisplay.cs(20,17): error CS0029: Cannot implicitly convert type string' to UnityEngine.UI.Text’
So I am assuming that string is not the right type.
could someone explain what i did wrong and give a Solution ?
Thanks
heres my Script :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ScoreDisplay : MonoBehaviour {
Text text;
private string score;
Playermovement playermovement;
void Start () {
text = GetComponent<Text> ();
playermovement = GetComponent<Playermovement> ();
}
void Update () {
score = playermovement.playerscore.ToString();
text = "Score:" + score;
}
}
(I am german. feel free to correct my english)
Thanks that solved it !!
– simonsasse97Don't forget to validate his answer if it did answered your question.
– Fluffy_Kaeloky