I tried to do a movement script but when player touches the ground it gets slower .i am using kinematic body

extends KinematicBody2D


var speed = 0
var maxspeed = 5000
var grav=200
var desped=35
var acsped=50


# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if Input.is_action_pressed("ui_right")and speed<=maxspeed:
		speed+=acsped
	elif Input.is_action_pressed("ui_left") and speed>=-maxspeed:
		speed-=acsped
	else:
		if speed>desped:
			speed-=desped
		elif speed>0:
			speed-=speed
		if speed<-desped:
			speed+=desped
		elif speed<0:
			speed+=-speed
	if maxspeed<speed:
		speed=maxspeed
	if -maxspeed>speed:
		speed=-maxspeed
	
	move_and_collide(Vector2(speed*delta,grav*delta))
	print(speed)

    mek02

    from https://docs.godotengine.org/en/stable/tutorials/physics/using_kinematic_body_2d.html :

    try moving into the obstacle at an angle and you'll find that the obstacle acts like glue - it feels like the body gets stuck
    This happens because there is no collision response. move_and_collide() stops the body's movement when a collision occurs. We need to code whatever response we want from the collision.

    Use move_and_slide . Let me fix your code:

    extends KinematicBody2D
    
    var speed = Vector2.ZERO
    var maxspeed = 5000
    var grav=200
    var desped: float = 0.1 #from value 0.0 to 1.0 (max)
    var acsped=50
    
    func _ready():
    	pass # Replace with function body.
    
    func _input(event):
    	if Input.is_action_pressed("ui_right"):
    		speed.x += acsped
    	if Input.is_action_pressed("ui_left"):
    		speed.x -= acsped
    
    func _physics_process(delta):
    	clamp(speed.x, -maxspeed, maxspeed)
    	
    	speed.x = lerp(speed.x, 0, desped)
    	speed.y = grav
    	
    	speed = move_and_slide(speed)
    	print(speed)

    EDIT: note that i did not use delta, use it here speed = move_and_slide(speed * delta) but then increase variable values (grav and acsped, I guess)