My code has no errors, but it doesn't work

I’m learning C# and doing my first project as a test. I tried to make the button disappear when user clicks on it, but nothing happens. Here’s the code:

public GameObject ButtonStart = new GameObject();

void Start ()
{
    ButtonStart.transform.position = new Vector2( 500 , 500 );
}

Try using this

using UnityEngine;
using UnityEngine.UI;

public class ButtonController : MonoBehaviour
{
    public Button button;

    private void Start()
    {
        // You can assign the Button component from the Unity Editor or find it by name/tag.
        // For example, if your button is named "StartButton":
        // button = GameObject.Find("StartButton").GetComponent<Button>();

        // Add a click event handler to the button
        button.onClick.AddListener(OnButtonClick);
    }

    void OnButtonClick()
    {
        // Hide the button when it's clicked
        button.gameObject.SetActive(false);
    }
}

please add the name of the button here in the 3rd line in the start function for it to work.