How to get the move function to make the x move negitave or positive when hitting a certain collision?

Godot 4.3

Hello! I am currently working on an enemy that moves, and moves in the opposite direction when hitting a collision, though I’ve been trying for hours, I can’t seem to find out how to do it.

NOTE: bruh and huh are both collisionshape2ds

CODE:

extends CharacterBody2D

var bruh = "res://scenes/miscellaneous/bruh.tscn"
var huh = "res://scenes/miscellaneous/collision_shape_2d2.tscn"
var direction = Vector2.AXIS_X
const jump_power = -900
const gravity = 50
const SPEED = 400

func _ready():
	move(1, 200)

func _physics_process(_delta):
	if is bruh:
		move(1, 200)
	if is huh:
		move(-1, 200)
	if is_on_wall_only():
		velocity.y += gravity

	move_and_slide()

func move(dir, speed):
	velocity.x = dir * speed