Sword Swinging Mechanic

Use look_at(get_global_mouse_position()) to rotate the sword.

And if you want the player sprite to face the cursor then this should work:

func _process(delta: float) -> void:
    if get_global_mouse_position().x < global_position.x:
        $player.flip_h = true
    else:
        $player.flip_h = false