only one command is executed after "if" statement, rest are ignored? help!

I’ve been googling my ass off but haven’t found sollution to this problem, so I have to loose my forum-virginity and ask for help. Basic noob stuff I’m sure, but I’m running out of brain power…

So the idea is that I want this script to change the boolean (OnOff) to “true” (which it does succesfully) when character touches the object where the script is attached to, but anything else I want the script to do is ignored. It doesn’t do debug logs or change any other variable anywhere else or anything I’ve tried, just changes this one boolean value. No error messages, and when compared to other similar scritps I’ve written, its basicly the same so should work.

Probably just some minor mistake but I hope someone can find it since I sure can’t. All help is much appreciated!

Here is the code:

using UnityEngine;
using System.Collections;

public class UseButton : MonoBehaviour {

public bool OnOff = false;
public GameObject checkBusted;
	
void OnControllerColliderHit(ControllerColliderHit hit) 
	{
	if (hit.collider.gameObject.tag == "Exit")
		{
		Debug.Log("pushed");
		checkBusted.GetComponent<Busted>().busted = true;
		OnOff = true;
		}
	}
}

This is a bit embarrasing, but the problem was that it was just attached to the wrong place. Nothing wrong with the code as such, just in wrong place. Sorry for wasting your time guys, live and learn :slight_smile: