Problem when trying to replace TextMeshPro text with code

Can’t add text to … because a textmeshproUGUI is already added to the game object! A game object can only contain one graphic component. Here is my code:

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

[RequireComponent(typeof(Text))]
public class Count2text : MonoBehaviour
{
    public float countDuration = 1;
    Text numberText;
    float currentValue = 0, targetValue = 0;
    Coroutine _C2T;

    void Awake()
    {
        numberText = GetComponent<Text>();
    }

    void Start()
    {
        currentValue = float.Parse(numberText.text);
        targetValue = currentValue;
    }

    IEnumerator CountTo(float targetValue)
    {
        var rate = Mathf.Abs(targetValue - currentValue) / countDuration;
        while(currentValue != targetValue)
        {
            currentValue = Mathf.MoveTowards(currentValue, targetValue, rate * Time.deltaTime);
            numberText.text = ((int)currentValue).ToString();
            yield return null;
        }
        
    }

    public void AddValue(float value)
    {
        targetValue += value;
        if (_C2T != null)
        StopCoroutine(_C2T);
        _C2T = StartCoroutine(CountTo(targetValue));
    }

    public void SetTarget(float target)
    {
        targetValue = target;
        if (_C2T != null)
        StopCoroutine(_C2T);
        _C2T = StartCoroutine(CountTo(targetValue));
    }
}

Thanks for any help!

Yeah well it does exactly what you tell it to do.
You Require it to have a Text Component but you already added a TextMeshPro Text Component. Those can not be on the same object. So for this reason you can also not add this script as component.

Decide what you want to have Text or TMPro.Text. Then change the script to require/use the correct one and you are good to go.