I’m trying to connect a bool from a script called “Inventory” to “Button2” so that if 5 coins are collected, the button to the door is allowed to be opened. I have tried the // stuff in the Void Start also, but this gives no result.
Try modifying the OnMouseDown() in the Button2 script, like this:
public void OnMouseDown()
{
bool canOpen = DoorOpenable.GetComponent<Inventory>().CanOpenDoor;
if(canOpen)
{
// Plays the audio clip...
AudioSource audio = GetComponent<AudioSource>();
audio.Play();
targetDoor3.GetComponent<Door3>().OpenDoor();
targetDoor4.GetComponent<Door3>().OpenDoor();
}
}