Godot Version
4.1.1
Question
I’m trying to make a sort of bobbing effect on a button, but if i run this code and the if statement is triggered, the tween keeps repeating endlessly instead of running once and letting my button move to the other side again. Does anyone know how to make a tween like this run only once?

You could cache the tween and check it. Or create a bool if the tween already was created.
var tween
func _process(delta):
if not tween:
tween = create_tween()...
Could you make this entire animation a tween using set_trans
?
func _ready() -> void:
var tween := create_tween().set_trans(Tween.TRANS_SPRING).set_ease(Tween.EASE_OUT)
var start_pos := position.x + 500
var end_pos := start_pos + x_end
tween.tween_property(self, "position:x", end_pos, 1.0).from(start_pos)