Trying to disable script on another game object

HI there im trying to disable a script on another game object as the title suggests I know theres a few good functions for this I just can’t seem to figure out why the code does not work

var hanging = false;


	//on collision
	function OnTriggerEnter(hit : Collider)	
    {
		if(hit.gameObject.tag == "Ledge")
		{
			
			transform.parent.GetComponent("PlatformerController").enabled = false;
			hanging = true;
			
		
		}
	
	}

function Update(){
if (Input.GetButtonDown ("Jump")  hanging == true ) {
								
			hanging = false;
//			GetComponent("Ledge").enabled = false;
			transform.parent.GetComponent("PlatformerController").enabled = true;
			transform.position += Vector3.up * 3;

		
			}
			
}

I’ve also tried making a Transform variable assiging the parent object, if I apply this version on the same gameobject I want to disable the script on it works fine but not when its applied to its child object (which is just a box collider with the script)

var hanging = false;
var player :Transform;

	//on collision
	function OnTriggerEnter(hit : Collider)	
    {
		if(hit.gameObject.tag == "Ledge")
		{
			
			player.GetComponent("PlatformerController").enabled = false;
			hanging = true;
			
		
		}
	
	}

function Update(){
if (Input.GetButtonDown ("Jump")  hanging == true ) {
								
			hanging = false;
//			GetComponent("Ledge").enabled = false;
			player.GetComponent("PlatformerController").enabled = true;
			transform.position += Vector3.up * 3;

		
			}
			
}

Thanks for any help.

hmm u r linking the correct game object to “Player” variable? i guess tht could be a problem

Thanks for the reply i got it working in a way using my first transform.parent.getcomponent code the problem is it only detects collisions if i put a chracter controller on the object if i create a empty game object and add a box collider and the script the collision is not detected (used Debug.Log to find out) anyone know why?.