Problem with modulating color of parallax background

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GodotBadger

I want to setup different colours for the background starfield in my game. If I call the set theme function from inside the parallax background instance it works ok. But if I call it externally the colour doesn’t change (although it appears to have changed when I look at the modulate property in the inspector). I’m modulating the sprites BTW, but also tried the same with the actual layers. Example below is the working version

extends ParallaxBackground

var _offset = 3
var _location = 0.0

func _process(delta):
_location = _location + _offset * delta
scroll_offset.y = _location

func set_background_theme():
print(Global.colours.size())
print(randi() % Global.colours.size())
var dict_colour = Global.colours[randi() % Global.colours.size()]
print(dict_colour)
Global.background_theme = Global.colour_schemes[dict_colour]
$Background.modulate = Global.background_theme[“background”]
$FarLayer.modulate = Global.background_theme[“FarSprite”]
$MidLayer.modulate = Global.background_theme[“MidSprite”]
$NearLayer.modulate = Global.background_theme[“NearSprite”]

func _on_Timer_timeout():
set_background_theme()
pass # Replace with function body.