Boolean from another script reads false even if i change it to true.

Basicly here i have one script, where i store my boolean.

using UnityEngine;
using System.Collections;

public class Block : MonoBehaviour
{
	public bool IsBlocking;
	public float blockcooldown = 2F;        
		
	    public void Awake ()
	    {
		}
	    void Update ()
		{
		blockpress ();
		blockstate ();
		Debug.Log (IsBlocking);
		}
	public void blockpress()
	{
		if (Input.GetButton ("Fire2") && blockcooldown >= 2F) {

						IsBlocking = true;
						blockcooldown = 0F;
			Renderer[] rs = GetComponentsInChildren<Renderer> ();
			foreach(Renderer r in rs)
				r.enabled =true;

				}
		else {
						blockcooldown += Time.deltaTime;
				}
				}
	public void blockstate()
	{
		if (blockcooldown >= 1.1F)
		{
			Renderer[] rs = GetComponentsInChildren<Renderer> ();
			foreach(Renderer r in rs)
				r.enabled = false;
			IsBlocking = false;
		}

	}

}

and if i try to read it in another code it reads as “false”, but as you can see i am also reading it’s state inside this code and it successfully says “true” after i press my right mouse button.

Does other code read only the public bool IsBlocking; ? Doesn’t IsBlocking change when i press my right mouse button?

Are you attaching the Block behavior to a gameObject? To fix this you’ll need to actually get the component from the gameObject that is Updating the blockpress() method.

block = gameObject.GetComponent<Block>();