An exported variable does not change when I try to change it in the inspector

Godot Version

4.7.1

Question

The code below is for a game object; it is specifically meant to manipulate the item’s sprite.

I want to be able to set the length of the sprite (it’s made up of repeating sections, and I want to set the number of sections).

When I drag length at the top of the inspector, however, it doesn’t move, although the Output dock records that I have Set length. When I comment out the setter, length does change when I drag it, and the sprite’s length updates once I put the setter back in. length is now stuck on the new value.

TrussSprite is a child of CharacterBody2D.

There are no references to length anywhere except in this code.

I know there are others who have had similar problems, but I couldn’t find any whose solution worked for me.

Why isn’t the exported variable allowing me to change it while the setter exists?

@tool
extends CharacterBody2D

@export var truss_sprite: Sprite2D

@export_range(1.0, 10.0) var length := 1.0 :
	set(new_length):
		truss_sprite.region_rect = Rect2(0.0, 0.0, 32.0 * length, 32.0)

Your setter doesn’t assign new_length to length.

omg thanks lol