Fps sway moving to the left indefinitly, no matter the mouse direction

Godot Version


extends Node3D

var mouse_move: float = 0.0
var sway_threshold = 0.1
var sway_lerp = 0.5

@export var sway_left : Vector3
@export var sway_right : Vector3
@export var sway_normal : Vector3

func _ready():

func _input(event: InputEvent) → void:
if event is InputEventMouseMotion:
mouse_move = -event.relative.x

func _process(delta):
if mouse_move != null:
if mouse_move > sway_threshold:
rotation = rotation.lerp(sway_left, sway_lerp * delta)
elif mouse_move < -sway_threshold:
rotation = rotation.lerp(sway_right, sway_lerp * delta)
rotation = rotation.lerp(sway_normal, sway_lerp * delta)
mouse_move = 0.0

i am attempting to make players gun move left/right depending on mouse input direction, the issue is that the weapon holder only moves to the left indefinitely no matter if the mouse is moving left or right until the gun is off screen permanently

What do you have sway_left, sway_right and sway_normal set to? Also, if you use the preformatted text option for code it’s much easier to read.