Invalid set index 'modulate' (on base: 'Nil') with value of type 'Color'

Hi so I’m pretty new to Godot and programming- basically I am making a maze game and I am trying to encode a feature where all the maze walls are dark when the payer starts out and then if they bump into light tiles the walls around them will light up for a timed interval to show them the way. so I used the scenes collection feature in the tile map so that I would be able to encode properties into the maze walls that I might not be able to if they were just a regular tile set.

The very first step of this in my eyes is to modulate the colour of the maze walls so that they start off dark and then work from there- but I am getting this error message.

I have all the different maze wall scenes stored inside a Node 2D (I’ll attach a picture of the tree structure below) and then the tiles themselves are all structured like this

StaticBody2D
– CollisionPolygon2D
– Sprite2D

(where collision polygon and sprite 2d are both children of static body 2d)

This is my code:

extends StaticBody2D

@export var sprite: Sprite2D

func _ready():
sprite.modulate = Color(0,0,0,1)

I have also tried it like this:

extends StaticBody2D

func _ready():
get_node(“Sprite2D”).modulate = Color(0,0,0,1)

Here I didn’t get an error but nothing happened? Not sure what to do.

This is the main scene node tree structure- the maze walls are at the bottom

can you try this:

@onready var sprite: Sprite2D = $Sprite2D

func _ready() -> void:
    sprite.modulate = Color(0, 0, 0, 1)

Tried it and the error is gone but the color doesn’t change :frowning: I feel like there’s something up with the way the nodes are communicating or the scene collection feature is messing with something

So you have maze walls as scene-collection tiles in the tilemap? What are the cell walls at the bottom of the scene tree then?