my game has 4-6 buttons.

hi, im having some problems with building a game with bunch of buttons. im trying to instantiate gameobject and are triggered by the answer buttons . im not sure if im doing it right but this is just one button ive created the rest is similiar to this. i clicked it works but trying to stop button fromm repeating again and

public GameObject objecttoDestroy;
bool isClick = true;
bool isWordPresented = true;
public  Button mybutton;

private void Start()
{
    
}

public void OnClickBLue()
{
    
        if (isWordPresented == true)
        {
            if (gameObject.CompareTag("blue"))
            {
                ScoreScirpt.scorevalue += 1;
                gameObject.GetComponent<Button>().interactable = false;
                 Destroy(objecttoDestroy);
            }

            else if (!gameObject.CompareTag("blue") && (!isWordPresented))
            {
                
                ScoreScirpt.scorevalue -= 1;
                mybutton.interactable.Equals(false);
                
            }
        }
    }

Are you trying to disable a button once you click on it? Your sample script is confusing, see my comment below. You might have miss a reference to the button and use getcomponent instead.


		if (isWordPresented == true)
		{
			if (gameObject.CompareTag("blue"))
			{
				ScoreScirpt.scorevalue += 1;

				// Does this gameobject contain the button script?
				gameObject.GetComponent<Button>().interactable = false;
				Destroy(objecttoDestroy);
			}
			else if (!gameObject.CompareTag("blue") && (!isWordPresented)) // Check for isWordPresented here is not necessary as you already check on top, you can even remove the whole "if" statemen here and just leave "else"
			{

				ScoreScirpt.scorevalue -= 1;

				// You are using a reference to a button here, is this the same button with the one on top where you use getcomponent?
				mybutton.interactable.Equals(false);

			}
		}

hi im sorry for being a bit confusing. but im trying to disable the function of the button from repeating again if continue to be pressed. if i keep on pressing i get continuosly keep gettting 1 point + and i want to stop it. i wnt to reset after is pressed and interactable again after a new game object is being instantiate. and YES each game object contains this script and then i add it to my ui button add functions