Code running before child nodes initialized

Godot Version

Godot Engine v4.4.1.stable.arch_linux

Question

Hey all, I’ve been working on a scene that has a root of a Node2D and has a Sprite2D as a child. I want to be able to change the Sprite2D’s sprite from the editor when the scene is added as a child, so I figured I would do something like this:

@tool
extends Node2D

@onready var sprite : Sprite2D = %Sprite

@export var starter_texture : Texture:
	get:
		return sprite.texture
	set(texture):
		sprite.texture = texture

However, whenever I open the editor or run the game, I get this error:

  ERROR: res://scripts/character.gd:10 - Invalid assignment of property or key 'texture' with value of type 'CompressedTexture2D' on a base object of type 'Nil'.

I assume this means that it’s running before the child nodes are initialized (base object of type ‘Nil’ is alluding to that). I’ve had a similar issue in the past, in which I used await get_tree().process_frame to wait until everything in the scene was initialized, but I don’t know how to do that here as it is in a getter/setter.

Here’s what my scene tree & whatnot look like:

I doubt that it will be related but here is the rest of the script:

@tool
extends Node2D

@onready var sprite : Sprite2D = %Sprite

@export var starter_texture : Texture:
	get:
		return sprite.texture
	set(texture):
		sprite.texture = texture

@onready var anims : AnimationPlayer = %AnimationPlayer

var flipped = false

func change_sprite(sprite: Texture) -> void:
	anims.play("squish start")
	await anims.animation_finished
	sprite.texture = sprite
	anims.play("squish end")
	await anims.animation_finished

func flip() -> void:
	if flipped:
		anims.play("flip 360")
	else:
		anims.play("flip 180")
	
	flipped = not flipped
	
	await anims.animation_finished

Via this reddit comment:

@export var starter_texture : Texture:
	set(texture):
		starter_texture = texture
		if is_node_ready():
			sprite.texture = texture
		
func _ready():
	sprite.texture = starter_texture