I am Making a Physics Based Cooking Game, I Followed a tutorial for godot 3 but the code doesnt work

Godot Version 4.3

So I followed this tutorial on how to make object picking but the tutorial was in godot 3. still with a few workarounds everything worked. except rotating objects.

I rewatched it twice and copied the code 1 to 1 but it didnt worked, now one thing i did notice was that he used deg2rad and godot told me to use deg_to_rad. I am not sure if that is a problem but i just wanted to put that here.

here is the snippet in my player controller responsible for rotating objects:
(Theres is way more in the code but that is the Important Stuff)

The Code

extends CharacterBody3D

@onready var staticBody: StaticBody3D = $Camera3D/StaticBody3D

var rotationForce = 0.5
var locked = false
var pickedObject

func _physics_process(delta: float) → void:
if !locked:
rotate_camera(delta)
move_and_slide()

func _input(event: InputEvent):
if Input.is_action_just_pressed(“rotate”):
locked = true
rotateobject(event)
if Input.is_action_just_released(“rotate”):
locked = false

func rotateobject(event):
if pickedObject != null:
if event is InputEventMouseMotion:
staticBody.rotate_x(deg_to_rad(event.relative.y * rotationForce))
staticBody.rotate_y(deg_to_rad(event.relative.x * rotationForce))

The Full Code

extends CharacterBody3D

@onready var interaction_ray: RayCast3D = $Camera3D/PickupRay
@onready var interaction_point: Marker3D = $Camera3D/interactionPoint
@onready var joint: Generic6DOFJoint3D = $Camera3D/Generic6DOFJoint3D
@onready var staticBody: StaticBody3D = $Camera3D/StaticBody3D
@onready var interactRay: RayCast3D = $Camera3D/InteractionRay

var pullForce = 6
var rotationForce = 0.5 # 0.05

var locked = false
var pickedObject
var sprinting = false

var capMouse = true

var look_dir: Vector2
@onready var camera: Camera3D = $Camera3D

func _ready() → void:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
var velocity: Vector3 = Vector3.ZERO

func _physics_process(delta: float) → void:
if not is_on_floor():
velocity += get_gravity() * delta * GlobalVars.GRAVITY

if Input.is_action_just_pressed(“sprint”):
sprinting = !sprinting

if sprinting:
GlobalVars.SPEED = GlobalVars.SPRINTING_SPEED
else:
GlobalVars.SPEED = GlobalVars.ORIGINAL_SPEED

if pickedObject != null:
var a = pickedObject.global_transform.origin
var b = interaction_point.global_transform.origin
var c = a.distance_to(b)
var calc = (a.direction_to(b))pullForcec
pickedObject.set_linear_velocity(calc)

if Input.is_action_just_pressed(“jump”) and is_on_floor():
velocity.y = GlobalVars.JUMP_VELOCITY

var input_dir := Input.get_vector(“left”, “right”, “up”, “down”)
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * GlobalVars.SPEED
velocity.z = direction.z * GlobalVars.SPEED
else:
velocity.x = move_toward(velocity.x, 0, GlobalVars.SPEED)
velocity.z = move_toward(velocity.z, 0, GlobalVars.SPEED)

if Input.is_action_just_pressed(“pause”):
get_tree().quit()

if !locked:
rotate_camera(delta)
move_and_slide()

func _input(event: InputEvent):
if event is InputEventMouseMotion: look_dir = event.relative * 0.01

if Input.is_action_just_pressed(“pick”):
if pickedObject == null:
pickObject()
elif pickedObject != null:
removeObject()

if Input.is_action_just_pressed(“rotate”):
locked = true
rotateobject(event)
if Input.is_action_just_released(“rotate”):
locked = false

if Input.is_action_just_pressed(“reset”):
get_tree().reload_current_scene()

func rotate_camera(delta: float, sens_mod: float = 1.0):
var input = Input.get_vector(“look_left”, “look_right”, “look_down”, “look_up”)
look_dir += input
rotation.y -= look_dir.x * GlobalVars.camera_sens * delta
camera.rotation.x = clamp(camera.rotation.x - look_dir.y * GlobalVars.camera_sens * sens_mod * delta, -1.5, 1.5)
look_dir = Vector2.ZERO

func rotateobject(event):
if pickedObject != null:
if event is InputEventMouseMotion:
staticBody.rotate_x(deg_to_rad(event.relative.y * rotationForce))
staticBody.rotate_y(deg_to_rad(event.relative.x * rotationForce))

func pickObject():
var collider = interaction_ray.get_collider()
if collider != null and collider is RigidBody3D:
pickedObject = collider
joint.set_node_b(pickedObject.get_path())

func removeObject():
if pickedObject != null:
pickedObject = null
joint.set_node_b(joint.get_path())