Godot v4.2
Can someone tell me how to get this character setup to flip correctly?
Currently, each of the characters have a scene similar to this:

The movement component is the node responsible for moving the characters, it has the following script:
extends Node2D
@onready var character_speed = get_parent().speed
@onready var character = get_parent()
var velocity = Vector2.ZERO
func _ready():
pass
func _process(delta):
handle_movement()
func handle_movement():
velocity = Vector2.ZERO
if(Input.is_action_pressed("move_right")):
velocity.x = 1
if(Input.is_action_pressed("move_left")):
velocity.x = -1
if(Input.is_action_pressed("move_down")):
velocity.y = 1
if(Input.is_action_pressed("move_up")):
velocity.y = -1
if(velocity.length() > 0):
velocity = velocity.normalized() * character_speed
if(velocity.x > 0):
character.scale.x = 1
if(velocity.x < 0):
character.scale.x = -1
func get_velocity():
return velocity
I try to flip the character scale here:
if(velocity.x > 0):
character.scale.x = 1
if(velocity.x < 0):
character.scale.x = -1
But when I try to do so, the character quickly flips between left and right. BUT only when moving to the left.