I have this error i dont know how to fix

Godot Version

<!-v4.2.stable.official →
here is the code

extends CharacterBody3D
#Player nodes
@onready var camera = $neck/head/eyes/camera
@onready var eyes = $neck/head/eyes
@onready var neck = $neck
@onready var head = $neck/head
@onready var crouchinghitbox = $crouchinghitbox
@onready var standinghitbox = $standinghitbox
@onready var ray_cast_3d = $RayCast3D
@onready var animation_player = $neck/head/eyes/AnimationPlayer
@onready var gun_camera = $neck/head/eyes/camera/SubViewportContainer/SubViewport/GunCamera

speed vars and amounts

@export var walking_speed = 5.0
@export var sprint_speed = 7.5
@export var crouching_speed = 2.5
@export var jump_valocity = 4.5
@export var neck_lerp_speed = 20.0
@export var mouse_sensetivity = 0.1

#crouching vars

var crouching_depth = -0.5

var current_speed = 5.0
var lerp_speed = 10.0
var air_lerp_speed = 3.0
var free_look_tilt_amount = 7.5
var last_velocity = Vector3.ZERO
#states
var walking = false
var sprinting = false
var crouching = false
var freelooking = false
var sliding = false

#slide vars
var slide_timer = 0.0
var slide_timer_max = 1.0
var slide_vector = Vector2.ZERO
var slide_speed = 10.0

#headbobbing vars

@export var headbobbing_sprinting_speed = 22
@export var headbobbing_walking_speed = 14
@export var headbobbing_crouhcing_speed = 10
@export var headbobbing_crouching_intensity = 0.05
@export var headbobbing_walking_intensity = 0.1
@export var headbobbing_sprinting_intensity = 0.2

var headbobbing_vector = Vector2.ZERO
var headbobbing_index = 0.0
var headbobbing_current_intensity = 0.0

var direction = Vector3.ZERO

Get the gravity from the project settings to be synced with RigidBody nodes.

var gravity = ProjectSettings.get_setting(“physics/3d/default_gravity”)

func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
$neck/head/eyes/camera/SubViewportContainer/SubViewport.size = DisplayServer.window_get_size()

func _input(event):
if event is InputEventMouseMotion:
if freelooking:
neck.rotate_y(deg_to_rad(-event.relative.x * mouse_sensetivity) )
neck.rotation.y = clamp(neck.rotation.y,deg_to_rad(-120),deg_to_rad(120))
else:
rotate_y(deg_to_rad(-event.relative.x * mouse_sensetivity) )
head.rotate_x(deg_to_rad(-event.relative.y * mouse_sensetivity) )
head.rotation.x = clamp(head.rotation.x,deg_to_rad(-89),deg_to_rad(89))

gun_camera.sway(Vector2(event.relative.x,event.relative.y))






if event.is_action_pressed("ui_cancel"):
	get_tree().quit()

func _physics_process(delta):

$neck/head/eyes/camera/SubViewportContainer/SubViewport/GunCamera.global_transform = camera.global_transform



#getting movement input
var input_dir = Input.get_vector("left", "right", "forward", "backward")


 # Slide begin logic
if Input.is_action_pressed("crouch") || sliding:
	current_speed = lerp(current_speed,crouching_speed, delta * lerp_speed)
	head.position.y = lerp(head.position.y,0.0 + crouching_depth,delta *lerp_speed)
	standinghitbox.disabled = true
	crouchinghitbox.disabled = false
	
	if sprinting && input_dir != Vector2.ZERO:
		sliding = true
		slide_timer = slide_timer_max
		slide_vector = input_dir
		freelooking = true
		
		print("slide begin")
	# states in crouch
	walking = false
	sprinting = false
	crouching = true
	
	
	
	
elif !ray_cast_3d.is_colliding():
	head.position.y = lerp(head.position.y,0.0 ,delta *lerp_speed)
	standinghitbox.disabled = false
	crouchinghitbox.disabled = true
	
	
	if Input.is_action_pressed("sprint"):
		current_speed = lerp(current_speed,sprint_speed, delta * lerp_speed)
		# states in sprinting
		walking = false
		sprinting = true
		crouching = false
		
	else:
		current_speed = lerp(current_speed,walking_speed, delta * lerp_speed)
		# states of walking	
		walking = true
		sprinting = false
		crouching = false




# freelook action

if Input.is_action_pressed("freelook") || sliding:
	freelooking = true
	eyes.rotation.z = -deg_to_rad(neck.rotation.y * free_look_tilt_amount)
	if sliding:
		#uselss code
		eyes.rotation.z = lerp(eyes.rotation.z, -deg_to_rad(7.0),delta * lerp_speed)
		# end of uselss code
		
	else:
		eyes.rotation.z = -deg_to_rad(neck.rotation.y * free_look_tilt_amount)

else:
	
	freelooking = false
	neck.rotation.y = lerp(neck.rotation.y,0.0, delta * lerp_speed)
	eyes.rotation.z = lerp(eyes.rotation.z,0.0,delta * lerp_speed)
	
# Handle sliding
if sliding:
	slide_timer -= delta
	if slide_timer <= 0:
		sliding = false
		freelooking = false
		print("slide end")

if not is_on_floor():
	velocity.y -= gravity * delta

# Handle jump
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
	velocity.y = jump_valocity
	sliding = false
	animation_player.play("jump")
	
	
	
#Handle landing
if is_on_floor():
	if last_velocity.y < -10.0:
		animation_player.play("Roll")
	elif last_velocity.y < -4.0:
		animation_player.play("Landing")
	
# Handle  headbob
if sprinting:
	headbobbing_current_intensity = headbobbing_sprinting_intensity
	headbobbing_index += headbobbing_sprinting_speed * delta
elif walking:
	headbobbing_current_intensity = headbobbing_walking_intensity
	headbobbing_index += headbobbing_walking_speed * delta
elif crouching:
	headbobbing_current_intensity = headbobbing_crouching_intensity
	headbobbing_index += headbobbing_crouhcing_speed * delta
if is_on_floor() && !sliding && input_dir != Vector2.ZERO:
	headbobbing_vector.y = sin(headbobbing_index)
	headbobbing_vector.x = sin(headbobbing_index/2)+0.5
	
	eyes.position.y = lerp(eyes.position.y,headbobbing_vector.y *(headbobbing_current_intensity/2.0),delta * lerp_speed)
	eyes.position.x = lerp(eyes.position.x,headbobbing_vector.x * headbobbing_current_intensity,delta * lerp_speed)
	
	
else:
	eyes.position.y = lerp(eyes.position.y,0.0,delta * lerp_speed)
	eyes.position.x = lerp(eyes.position.x,0.0,delta * lerp_speed)


# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
if is_on_floor():
	direction = lerp(direction,(transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized(),delta*lerp_speed)
else:
	if input_dir != Vector2.ZERO:
		direction = lerp(direction,(transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized(),delta*air_lerp_speed)
		 
if sliding:
	direction = (transform.basis * Vector3(slide_vector.x,0,slide_vector.y)).normalized()
	current_speed = (slide_timer +0.1) * slide_speed
	
if direction:
	velocity.x = direction.x * current_speed
	velocity.z = direction.z * current_speed

else:
	velocity.x = move_toward(velocity.x, 0, current_speed)
	velocity.z = move_toward(velocity.z, 0, current_speed)
	
	

	
last_velocity = velocity

move_and_slide()

Question

am getting this error when I move and I have no idea what’s the cause triggering it to happen
the error is :ivalid get index ‘relative’ (on base: ‘InputEventKey’).
it happend when i added this line of code:
gun_camera.sway(Vector2(event.relative.x,event.relative.y))
sway reffrences:
extends Camera3D
@onready var fps_rig = $fps_rig

Called when the node enters the scene tree for the first time.

func _ready():
pass # Replace with function body.

#region New Code Region

Called every frame. ‘delta’ is the elapsed time since the previous frame.

func _process(delta):

fps_rig.position.x = lerp(fps_rig.position.x,0.0,delta * 5)
fps_rig.position.y = lerp(fps_rig.position.y,0.0,delta * 5)

#endregion
func sway(sway_amount):
fps_rig.position.x += sway_amount.x * 0.005
fps_rig.position.y += sway_amount.y * 0.005

>

There is no relative property of the event which is an InputEvent, hence why the error