Mouse position is off.

The mouse position is off when I click and drag objects with this script.

public string pieceStatus = "";

private void Update()
{
    if (pieceStatus == "PickedUp")
    {
        Vector2 mousePosition = Input.mousePosition;
        Vector2 objPosition = Camera.main.ScreenToWorldPoint(mousePosition);
        transform.position = objPosition;
    }
}

private void OnMouseDown()
{
    pieceStatus = "PickedUp";
}

private void OnMouseUp()
{
    transform.position = new Vector3(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y), transform.position.z);

    pieceStatus = "idle";
}
private void OnMouseOver()
{
    if (Input.GetMouseButtonDown(1))
    {
        transform.Rotate(0, 0, 90);
    }
}

I’ve debugged it so I know that the mouse position is off.

Hey I found a really simple script that does everything that I need it to do

here it is

Vector3 mousePositionOffset;
public GameObject thing;

private Vector3 GetScreenToWorldPoint()
{
    return Camera.main.ScreenToWorldPoint(Input.mousePosition);
}

private void OnMouseDown()
{
    mousePositionOffset = transform.position - GetScreenToWorldPoint();
}

private void OnMouseDrag()
{
    transform.position = GetScreenToWorldPoint() + mousePositionOffset;
}

private void OnMouseUp()
{
    transform.position = new Vector3(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y), transform.position.z);
}

private void OnMouseOver()
{
    if (Input.GetMouseButtonDown(1))
    {
        transform.RotateAround(thing.transform.position, Vector3.forward, 90);
    }
}

thanks for all the help
and sorry for any confusion I might have caused