hide child object script - help

hi all,

i have been playing around with this script for a longtime and it still doesn’t work, what is suppose to happen is my player collides with the trigger, “B” is pressed then the CHILD of the object to hide, here is myscript

function OnTriggerStay(trigger : Collider) {
     if((trigger.gameObject.tag == "Player") && Input.GetKeyDown(KeyCode.B)) {
      renderer.enabled = false;

how would i change this script so that it hides the child object?

any help/ amendments would be great


There’s nothing wrong with the code.

Try to make sure of the following:

Is the player character tagged as “Player”

Does the player character have a rigidbody attached?(it should)

Does the player have a collider?(it should)

Does the Object to be hidden have a collider?(it should)

is the collider on the object to be hidden set to “IsTrigger”?(it should)