Need help with Tweens: Cannot call method 'set_delay' on a null value

Godot Version

4.3.beta1

Question

I want to implement a damage over time mechanic for my game using Tweens.

Sometimes, when calling this function I get the error message Cannot call method 'set_delay' on a null value.

What am I doing wrong here? How can I fix this behaviour?

func take_damage_over_time(damage_per_tick: int, loops: int, delay: float) -> void:	
	if damage_over_time_tween == null:
		damage_over_time_tween = create_tween()
	
	if damage_over_time_tween.is_running():
		damage_over_time_tween.kill()
		damage_over_time_tween = create_tween()
	
	damage_over_time_tween.set_loops(loops)
	damage_over_time_tween.tween_callback(take_damage.bind(damage_per_tick)).set_delay(delay)