Cannot get variable from child node

Godot Engine v3.5.2

I have a parent node, a VBoxContainer child and a CentreContainer Grandchild (with texture rect great grandchild).

image

The CentreContainer has a script which gives a variable Box1_1Colour, which on init is defined as Box1_1Colour = 15

extends CenterContainer

var filled
var Box1_1Colour

func _init():
filled = 1
Box1_1Colour = 15

image

In the Root Node, I want to have a variable ColourSelected that picks up the variable value of Box1_1Colour (ie 15) when a button is clicked and other conditions are met

image

extends Node2D

var ColourSelected

func _on_Tube1Button_pressed():
if Tube2Pour == 0 and Tube3Pour == 0 and Tube4Pour == 0 and Tube5Pour == 0:
Tube1Pour = 1
print (“Tube 1 Pour”, Tube1Pour)
if $Tubes/Cont1/Box1_1.filled == 0:
if $Tubes/Cont1/Box1_2.filed == 0:
if $Tubes/Cont1/Box1_3.filled == 0:
if $Tubes/Cont1/Box1_4.filled == 0:
ContSelected = $Tubes/Cont1/Box1_4
ColourSelected = $Tubes/Cont1/Box1_4.Box1_4Colour
elif $Tubes/Cont1/Box1_4.filled == 1:
ContSelected = $Tubes/Cont1/Box1_3
ColourSelected = $Tubes/Cont1/Box1_3.Box1_3Colour
elif $Tubes/Cont1/Box1_3.filled == 1:
ContSelected = $Tubes/Cont1/Box1_2
ColourSelected = $Tubes/Cont1/Box1_2.Box1_2Colour
elif $Tubes/Cont1/Box1_2.filled == 1:
ContSelected = $Tubes/Cont1/Box1_1
ColourSelected = $Tubes/Cont1/Box1_4.Box1_4Colour
print (ColourSelected)

At the moment, print returns Null. If I change it from colour selected to $Tubes/Cont1/Box1_4.Box1_4Colour, it prints 15, however it seems if I try and link it to the variable ColourSelected it no longer works.

Does anyone know what I am doing wrong and how I can fix it?

Your post is quite difficult to read.

Please replace the images of code with the actual code as text.

Like this:
```gdscript

Code here

```

Then it will look like this:


Code here

Maybe box 1 filled is equal to 1 so it skips the whole code block