CharacterBody2D does not recognise sibling Control node

Godot Version

Question

I have the following line in the _process function of CharacterBody2D: $Control/TextureButton.hide()
When run, this line returns Attempt to call function 'hide' in base 'null instance on a null instance.
How do I fix it?

That means, that you do you do not reference an existing Node in your scene tree.
Based on $Control/TextureButton.hide() you try to access a node in the following scene tree:

  • CharactedBody2D ← your code runs in this node
    • Control
      • TextureButton ← this is the node, that you try to hide

The error message means, that in your scene tree

  • there is no child of CharacterBody2D with a name of Control or
  • there is no child of Control with a name of TextureButton

Do your nodes have different names?

The path looks like this:
>Parent Node (node)
>>CharacterBody2D
>>Control
>>>Textutebutton

So Control is a sibling of CharacterBody2D.
Something like this should work, because you need to access the sibling via the parent node: $"../Control/TextureButton".hide()

But I wouldn’t suggest to use this usage pattern, because traversing the scene tree over parent nodes easily breaks when you change your setup of the scene tree.