- Edited
So, I'm making a loading screen, and I've written this code:
extends Control
#GUI
@onready var color_rect = $ColorRect
@onready var label = $Label
func _ready():
var colors = [Color.BLACK,Color.AQUA,Color.CORNFLOWER_BLUE,Color.CHARTREUSE,Color.DARK_TURQUOISE,Color.CRIMSON,Color.DARK_RED,Color.DEEP_PINK,Color.ORANGE,Color.ORANGE_RED,Color.GOLD,Color.WHITE,Color.TOMATO,Color.TEAL]
color_rect.color = colors.pick_random()
if color_rect.color == Color.WHITE or color_rect.color == Color.GOLD:
label.modulate = Color.BLACK
This is the hierarchy of the scene, the previous script is attached to the root:
When I launch the scene I get this error: "Invalid set index 'color' (on base: 'null instance') with value of type 'Color'.", as if the ColorRect did not exist... why?? I did not rename it, and it is in the hierarchy, why is it not detecting it?