Tween rotation offsets when spammed

Godot Version

4.2.1

Question

I made a simple 90° camera turn animation using tweens but found out that when the trigger is spammed the camera angle offsets from the original 90 degree increments.

I believe it’s because the tween starts again from where the other one was at that time, so i tried some ways to make it run only if there wasn’t another running already but can’t get none to work

Original code:

func _on_lefttrigger_mouse_entered():

	var tween = create_tween()
	tween.tween_property(player, "rotation:y" , deg_to_rad(90) , 0.2).as_relative()

Prevents tween from running at all:

	var tween = create_tween()
	if tween.is_running() == false:
		tween.tween_property(player, "rotation:y" , deg_to_rad(90) , 0.2).as_relative()
	var tween = create_tween()
	if tween and tween.is_running():
		return
	tween.tween_property(player, "rotation:y" , deg_to_rad(90) , 0.2).as_relative()

Same behavior:

	var tween = null
	if tween:
		return
	tween = create_tween()
	tween.tween_property(player, "rotation:y" , deg_to_rad(90) , 0.2).as_relative()
	tween.kill
	tween = null
	var tween = null
	if not tween:
		tween = create_tween()
		tween.tween_property(player, "rotation:y" , deg_to_rad(90) , 0.2).as_relative()
		tween.kill
		tween = null

Check the Tween documentation page. It’s explained there.

var tween:Tween

func _on_lefttrigger_mouse_entered():
	if tween:
		tween.kill()
		
	tween =  create_tween()
	tween.tween_property(player, "rotation:y" , deg_to_rad(90) , 0.2).as_relative()

Still does the same thing