Code Not working

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

public class Size_Changer : MonoBehaviour
{
    public Vector3 maxLocalScale;
    float maxlocalScaleMagnitude;
    public Text CountText;

    void Start()
    {

        maxLocalScale = new Vector3(0.1F, 1, 0.1F);
        maxlocalScaleMagnitude = maxLocalScale.magnitude;
        CountText = GameObject.Find("CountTextObject"); // No work line
    }


    void LateUpdate()
    {

        float actualLocalScaleMagnitude = transform.localScale.magnitude;
        if (actualLocalScaleMagnitude < maxlocalScaleMagnitude)
        {

            transform.localScale += new Vector3(0.0005F, 0.001F, 0.0005F);
        }

        else
        {
            Score1.score++;
            print("your score is now:" + Score1.score);
            Destroy(gameObject);
            CountText.text = Score1.score.ToString ();


        }
    }
}

// Assets/Scripts/Size_Changer.cs(17,32): error CS0029: Cannot implicitly convert type //UnityEngine.GameObject' to UnityEngine.UI.Text’

Good day @nzmichael118 !

In line 10 you defined CounText as a Text component

 public Text CountText;

But at line 17, you are looking for a gameobject called CountText, but Countext is not an object, is a component Text from some object

CountText = GameObject.Find("CountTextObject");

So, you should define Countextxt as text component of the object:

CountText = GameObject.Find("CountTextObject").GetComponent<Text>();

So now, yes, CountText.text can be edited with

CountText.text = Score1.score.ToString ();

If this post helps, mark as good and upvote!

If need more help, just ask using @tormentoarmagedoom

Bye :smiley: !