making buuffer clicks not work on walls

Hi, I am pretty new to godot and I’m enjoying it so far. But I have a problem. I followed some random tutorial on yt and because its a bit outdated I had to change some things. I added a wall jump, buffer jump, cyote jump and a double jump should exist too. The thing is, the double jump doesnt work even tho i followed the tutorial and the buffer jump is totally buggy. I dont know what to do so I am asking for help in here

here is my code btw:

extends CharacterBody2D

var max_speed : int = 400
var max_fall_speed : int = 2000
var acceleration : int = 50
var gravity : float = 35
var jump_force : int = 1000
var jump_timeout : int = false
var buffer_time : int = 15
var cayote_time : int = 15

var jump_counter : int = 0
var buffer_counter : int = 0
var cayote_counter : int = 0

func _physics_process(delta):

if is_on_floor():
	cayote_counter = cayote_time
	jump_counter = 0

if not is_on_floor():
	if cayote_counter > 0:
		cayote_counter -= 1
	
	if buffer_counter > 0 :
		if $RayCast2D.is_colliding():
			if $RayCast2D.get_collider().name == "TileMap":
				cayote_counter = 1
				velocity.x -= 400
		elif jump_counter < 1:
			cayote_counter = 1
			jump_counter += 1

	if buffer_counter > 0 :
		if $RayCast2D2.is_colliding():
			if $RayCast2D2.get_collider().name == "TileMap":
				cayote_counter = 1 
				velocity.x += 400
		elif jump_counter < 1:
			cayote_counter = 1
			jump_counter += 1

	velocity.y += gravity
	if $RayCast2D.is_colliding():
		if $RayCast2D.get_collider().name == "TileMap":
			velocity.y = 250
			
	else:
		if velocity.y > 2000:
			velocity.y = max_fall_speed

if Input.is_action_pressed("move_right") and not Input.is_action_pressed("move_left"):
	velocity.x += acceleration
	$Sprite2D.flip_h = false

elif Input.is_action_pressed("move_left") and not Input.is_action_pressed("move_right"):
	velocity.x -= acceleration
	$Sprite2D.flip_h = true
		
	if velocity.x < 0:
		velocity.x = -6000

else:
	velocity.x = lerp(velocity.x,0.0,0.1)

velocity.x = clamp(velocity.x, -max_speed, max_speed)

if not jump_timeout:
	if Input.is_action_just_pressed("jump"):
		$Timer.start(0.35)
		jump_timeout = true
		buffer_counter = buffer_time

if buffer_counter > 0:
	buffer_counter -= 1

if buffer_counter > 0 and cayote_counter > 0:
	velocity.y = -jump_force
	cayote_counter = 0

if Input.is_action_just_released("jump"):
	if velocity.y < 0:
		velocity.y += 400

move_and_slide()

func _on_timer_timeout():
jump_timeout = false