move one object when i click another

I’m trying to make a code for a “Dice Game” my friend asked me to make, im not all that experienced in C# coding yet so i need help. Basically i need to move “Object A” to “Object B” and then back, and still be able to have Object A do something at the same time. I have a few pieces of code written this one moves one object, “Cup”, to the other, “Dice”, but not the way i want it to, here it is:

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

public class CupScript : MonoBehaviour
{

    IEnumerator Cup()
    {
        transform.position = new Vector3(2.76f, 0, transform.position.z);

        yield return new WaitForSecondsRealtime(2);

        transform.position = new Vector3(-3, 0, transform.position.z);
    }

    void OnMouseDown()
    {
        StartCoroutine("Cup");
    }
}

Public GameObject posA, posB;

void MoveObject ()
{
Vector2 move;

move  = Vector2.MoveTowards(posA.transform.position, posB.position, step);
                 transform.position = move;
}