Tween is moving off sideways after completing animation

Godot Version

4.2.2

Question

Hello, running into a weird issue with tweening damage numbers. It seems that after doing the initial up->down movement, it seems the label moves sideways and I am not sure why that is the case. Brief video of the issue.

This is the whole code (taken from a youtube tutorial that doesn’t have this issue)

func display_number(value: int, position: Vector2, is_critical: bool = false):
    var number = Label.new()
    number.global_position = position
    number.text = str(value)
    number.z_index = 19
    number.label_settings = LabelSettings.new()

    var colour = "#FFF"
    if is_critical:
        colour = "#B22"

    if value == 0:
        colour = "#FFF8"

    number.label_settings.font_color = colour
    number.label_settings.font_size = 18
    number.label_settings.outline_color = "#000"
    number.label_settings.outline_size = 1
    
    call_deferred("add_child", number)
    await number.resized
    number.pivot_offset = Vector2(number.size / 2)

    var tween = get_tree().create_tween()
    tween.set_parallel(true)
    tween.tween_property(
        number, "global_position:y", number.position.y - 48, 0.5
    ).set_ease(Tween.EASE_OUT)
    tween.tween_property(
        number, "global_position:y", number.position.y, 1
    ).set_ease(Tween.EASE_IN).set_delay(0.5)
    tween.tween_property(
        number, "scale", Vector2.ZERO, 0.5
    ).set_ease(Tween.EASE_IN).set_delay(1)

    await tween.finished
    number.queue_free()

Not really sure why the label is moving, I can see it being added to the top of the tree by itself (not under enemy nodes). So confused why it moves in x direction after finishing the initial up->down movement.

Thanks for taking a look!

Control nodes Control.scale uses the Control.pivot_offset property as its origin. By default is the top-left corner. You’ll need to change the Control.pivot_offset property to the center of the Label for the scale to look fine.