how to reuse scripts with string changes

i am making a “interaction text” script for a little project i am working on. the way it is going to work was that it says a description for interactable objects like “this is a shovel” or things like that. the way i have done it so far is that i have given a script to the canvas with a method (or a function i don’t remember what its called) that sets the ui text’s text and then made a script i gave to a object making it change the text if collision is detected with the player then make it play a “fade in fade out” animation for the text.

the problem right now is that i don’t know how to change the script for each object without making tons and tons of copies and change the one detail.

[SerializeField] public InventoryMenu inventoryMenu;
[SerializeField] public GameObject playerObject;
[SerializeField] public Collider player;
private bool fPressed = false;
private bool trigger = false;
Animator invAnim;

// Start is called before the first frame update
void Start()
{
    
    invAnim = inventoryMenu.GetComponent<Animator>();
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.F) && trigger) { fPressed = true; }
}

private void OnTriggerStay(Collider other)
{
    if (other == player)
    {
        inventoryMenu.SetInteractText("F to Examine");
        if (fPressed) { invAnim.Play("ActionTextUp"); fPressed = false; }
    }    
}

private void OnTriggerEnter(Collider other)
{
    if (other == player)
    {   
        trigger = true;
        inventoryMenu.SetActionText("Its a sphere");
    }
}

private void OnTriggerExit(Collider other)
{
    if (other == player)
    {
        trigger = false;
        inventoryMenu.SetInteractText("");
    }
}

here is the script i am using thanks!

Just make a public string variable at the start of your script and then when you use SetActionText, you can just use the string variable instead of hard coding in a string. This means you can put that script on multiple different GameObjects and just change the string in the inspector and it will work.