Calling a node from within script

Hello! So I’m trying to make it so a random child node of a specific parent gets made visible. If I manually make these visible the script works perfectly, but as soon as I add them to a dictionary and attempt to call them I am hit with a "Node not found: -------- (in relation to blahblahblah)

I’m sure this must be some kind of pathing issue that if I had a better general understanding of programming I would see but alas I do not.

My pathing looks something like this. I am trying to call one of the 2 texturerects

 -Area2D (attached script)
  -Unimportant Node
  -Unimportant Node
  -Unimportant Node
  -Window (Unimportant connection)
    -Canvas Layer
      -TextureRect
      -TextureRect

Can you share your code and point out the line that gives you the error?

If you can get the canvas layer (assuming $"Window/Canvas Layer" works?) you can get all of it’s children and pick a random one to operate on.

var children: Array[Node] = $"Window/Canvas Layer".get_children()
var random_one: Node = children.pick_random()
random_one.show()

Hi there! Thank you for this, I hadn’t understood that you had to call the entire path ie with a " / ", I had assumed it would just find it if its a child of a child.

I’m still learning syntax haha. Another problem I have is declaring variables. Because when I use your provided code it returns the error of not knowing what “random_one” is. I think I’m missing a basic step along the way?

Edit: I fixed the problem haha. Indentations innit