I can't drag text into my script

I can’t drag text into my script

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

public class AudSys : MonoBehaviour
{
    public Text volumeAmount;

    public void SetAudio(float value)
    {
        AudioListener.volume = value;
        volumeAmount.text = ((int)value * 100).ToString();
    }
}

So… what’s the problem? You should be able to see the volumeAmount Text in the inspector.
Does the object you attempt to drag there have a Text component?

yes ?

Is it the correct Text type? Do you have any errors in your console? What happens when you drag it there?

This would be easier if you provided a bit more information.

There’s about 7 or 8 different things that one might call “Text” in Unity.

If it isn’t the UnityEngine.UI.Text component (what your script is asking for above) it won’t slot in.

TMPro texts won’t slot in, UIElement texts won’t slot in, and the old legacy TextMesh won’t slot in either.

Instead of dragging you can click on the volumeAmount field in the inspector and that will open a box with the available choices.

TMPro maybe???

using TMPro;

public class GameManager : MonoBehaviour
{
      public TextMeshProUGUI volume;

}

AudioListener Is defined. Your script has errors and won’t compile so it’s not working.

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

public class AudSys : MonoBehaviour
{
    public Text volumeAmount;

    // Reference to the AudioListener component assigned in the Inspector
    public AudioListener audioListener;

    public void SetAudio(float value)
    {
        if (audioListener != null)
        {
            audioListener.volume = value;
            volumeAmount.text = ((int)(value * 100)).ToString();
        }
        else
        {
            Debug.LogWarning("AudioListener is not assigned.");
        }
    }
}

Just a note to look into using log to manage your audio volume. It’s best not to linearly scale audio volume as db doesn’t work like that.