Character sprite stutters when it moves

Godot Version

Godot 4

I’m trying to make a simple first project, and the problem is that whenever the sprite moves on the screen, it glitches. It may have something to do with the code. Any help would be appreciated.

First, do not multiply the delta with velocity. Second, do not add or subtract the velocity, just simply assign its value. And there are more issues.

Here is the correct codes:

var input_direction = Input.get_axis("left", "right", "up", "down")
velocity = lerp(velocity, input_direction * speed, delta*(10.0 if input_direction else 7.0))
move_and_slide()

I wrote the codes in the shortest way. This is the whole codes of the movement in physics process. Here 10.0 is the acceleration and 7.0 is the friction (when player stops, it slides a bit if I am not wrong). Higher value means it stops faster and lower value means it stops slower (as like it slide which known as friction or acceleration that what I think).