Second tween not working after await

Godot Version

Godot version: 4.6

Question

I’m making a health bar for my game, I’m using an @tool script to tween the sizes on control nodes. These work fine if I have the tweens run at the same time but if I want a tween to run after an await the tween doesn’t work. I know that the await finished because if i put a print after that still works

Also doesn’t work when game runs

I’ve put “# doesn’t work” after the tweens that don’t work. - always the second tween is broken after an await

Does anyone have any ideas on why this breaks them?

var barTween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
var barBackTween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CIRC)

if isLess:#ignore isLess
	barTween.tween_property($Health, "size:x", barsize, .1)
	await barTween.finished # breaks waiting for tween
    print("Finished") # works
	barBackTween.tween_property($HealthTween, "size:x", barsize + 50, 1) # doesn't work
elif not isLess: #ignore isLess
	#heal
	barBackTween.tween_property($HealthTween, "size:x", barsize + 50, 1)
	await get_tree().create_timer(.8).timeout # breaks with timer
	barTween.tween_property($Health, "size:x", barsize, 0.25)# doesn't work

Tweens clean themselves up after finishing, you cannot add tween_property onto a finished (or even started) tween.

you don’t need to await finished as tween_property will by default start after the last one finishes. It seems like you can just use one tween for both situations

if isLess:
	barTween.tween_property($Health, "size:x", barsize, .1)
	barTween.tween_property($HealthTween, "size:x", barsize + 50, 1)

If you want to wait a fixed amount between tweens you can use tween_interval and/or set_delay with a parallel tween

elif not isLess:
	#heal
	barTween.set_parallel() # following tweens run at the same time
	barTween.tween_property($HealthTween, "size:x", barsize + 50, 1)
	barTween.tween_property($Health, "size:x", barsize, 0.25).set_delay(0.8) # but this one is delayed

Thanks, set_delay() worked wonders.