This is my script:

public GameObject caj_closed, caj_opened, intText, lockedtext;
	public AudioSource open, close;
	public bool cajopen, cajlocked;
	public static bool keycajon;
	
	void Start(){
		keycajon = false;
	}
	void OnTriggerStay(Collider other){
		if(other.CompareTag("MainCamera")){
			if(cajopen == false){
				if(cajlocked == false){
					intText.SetActive(true);
					if(Input.GetKeyDown(KeyCode.E)){
						caj_closed.SetActive(false);
						caj_opened.SetActive(true);
						intText.SetActive(false);
						StartCoroutine(repeat());
						cajopen = true;
					}
				}
				if(cajlocked == true){
					lockedtext.SetActive(true);
				}
			}
		}
	}
	void OnTriggerExit(Collider other){
		if(other.CompareTag("MainCamera")){
			intText.SetActive(false);
			lockedtext.SetActive(false);
		}
	}
	IEnumerator repeat(){
		yield return new WaitForSeconds(4.0f);
		caj_opened = false;
		caj_closed.SetActive(true);
		caj_opened.SetActive(false);
		close.Play();
	}
	void Update(){
		if(keycajon == true){
			cajlocked = false;
		}
	}
}

Its a direct copy just changing some names of this other script, which works PERFECTLY!


public GameObject door_closed, door_opened, intText, lockedtext;
public AudioSource open, close;
public bool opened, locked;
public static bool keyfound;

void Start(){
	keyfound = false;
}
void OnTriggerStay(Collider other){
	if(other.CompareTag("MainCamera")){
		if(opened == false){
			if(locked == false){
				intText.SetActive(true);
				if(Input.GetKeyDown(KeyCode.E)){
					door_closed.SetActive(false);
					door_opened.SetActive(true);
					intText.SetActive(false);
					StartCoroutine(repeat());
					opened = true;
				}
			}
			if(locked == true){
				lockedtext.SetActive(true);
			}
		}
	}
}
void OnTriggerExit(Collider other){
	if(other.CompareTag("MainCamera")){
		intText.SetActive(false);
		lockedtext.SetActive(false);
	}
}
IEnumerator repeat(){
	yield return new WaitForSeconds(4.0f);
	opened = false;
	door_closed.SetActive(true);
	door_opened.SetActive(false);
	close.Play();
}
void Update(){
	if(keyfound == true){
		locked = false;
	}
}

}

And I dont know whats wrong, can anyone help me?

Hello.

Read your error code.

It says Script name CS: line of the code where the error occurs , in your case line 29 and then the error itself , in your case “Cannot implicitly convert type ‘bool’ to 'UnityEngine.GameObject”

This means at line 29 you are using a bool variable as it were a GameObject variable. So unity its sayin you that can not transform a “bool” into a “GameObject”

Bye.