I'm guessing you've watched HeartBeast, it's a great channel, I've learned a lot and still learning there, so heres is some improvements you can do, you may copy the code but please, study it, undertand how it works
some tips:
*setting up a direction system is great to do movement with less code, like this I've used get_action_strength to give 1 and -1 for the buttons pressed, then multiplying for the speed
*sprite.flip_h = motion.x < 0 avoid checking for the side your looking every time
*you set up a run_right and left button, but never changes the speed, I don't see how it works, maybe you were still working on it
*I think is better to saparate every thing in variables, like: friction, air_friction, onready var sprite = $Sprite, maybe a wall_friction, a input_run..
Good Luck! :)
extends KinematicBody2D
var motion = Vector2.ZERO
const gravity = 1200
const walk_speed = 250
const run_speed = 500
const acceleration = 50
const jump_force = -550
func _physics_process(delta):
motion.y += gravity * delta
var input_direction = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
var input_run = Input.is_action_pressed("ui_run")
$Sprite.flip_h = motion.x < 0
if input_direction:
motion.x += input_direction * acceleration
if !input_run:
motion.x = clamp(motion.x, -walk_speed, walk_speed)
else:
motion.x = clamp(motion.x, -run_speed, run_speed)
if is_on_floor():
if !input_direction:
motion.x = lerp(motion.x, 0, 0.2)
if Input.is_action_just_pressed("ui_up"):
motion.y = jump_force
else:
if !input_direction:
motion.x = lerp(motion.x, 0, 0.05)
motion = move_and_slide(motion, Vector2.UP)