How to convert float to string?

Unity gave me the error message “error CS0029: cannot implicitly convert type ‘float’ to ‘string’”

My code is

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

public class DisplayScore : MonoBehaviour
{
    public Text test;
    public bool flag = true;

    // Use this for initialization
    void Update()
    {
            test.text = GameObject.Find("Button Score").GetComponent<ButtonClick>().playerScore;
    }
}

so how would I convert the float to a string? ty!

Add .ToString() at the end :slight_smile:

thanks! :slight_smile:

If you’re lazy like me you can also do +“” … I think it does .ToString() implicitly … so for example:

void Start()
{
    float f = 3.141f;
    PrintString(f+"");
}

void PrintString(string s)
{
    Debug.Log(s);
}