I am having trouble implementing a Varying Jump Height Mechanic

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Help_da_Noob
Hi, first of all I want to mention that English is not my mother tongue, and that I am only 16, so I don't have any prior programming experience, although, I understand what certain thing do :)))

I am working on my first video game, and I want to implement a "Varying Jump Height Mechanic" for my character. I try to make the controls feel like a hybrid between "Super Mario Bros 1, Super Castlevania IV, Super Meat-Boy and Mega Man 7"

For now, I managed to give the player the desired air control, however, without having   the possibility to control the height of the jump, the movement will feel quite sloppy.

One more thing before I give you the script, all the sprites are placeholders for now if that has to do with anything.

extends KinematicBody2D

const SPEED = 125
const GRAVITY = 18
const JUMP_POWER = -325
const FLOOR = Vector2(0, -1)

const FIREBALL = preload(“res://Fireball.tscn”)

var velocity = Vector2()

var on_ground = false

var is_dead = false

func _physics_process(delta):

if is_dead == false:
	 if Input. is_action_pressed("ui_right"):
		 velocity.x = SPEED
		 $AnimatedSprite.flip_h = true
		 if sign($Position2D.position.x) == -1:
			 $Position2D.position.x *= -1
	 elif Input. is_action_pressed("ui_left"):
		 velocity.x = -SPEED
		 $AnimatedSprite.flip_h = false
		 if sign($Position2D.position.x) == 1:
			  $Position2D.position.x *= -1
		 velocity.x = 0
		 if on_ground == true:

	 if Input. is_action_pressed("ui_up"):
		 if on_ground == true:
			 velocity.y = JUMP_POWER
			 on_ground = false 
	 if Input. is_action_just_pressed("ui_focus_next"):
		 var fireball = FIREBALL.instance()
		 if sign($Position2D.position.x) == 1:
		 fireball.position = $Position2D.global_position
	 velocity.y += GRAVITY

	 if is_on_floor():
		 on_ground = true 
		 on_ground = false
		 if velocity.y < 0:

	 velocity = move_and_slide(velocity, FLOOR)

	 if get_slide_count() > 0:
		 for i in range(get_slide_count()):
			 if "Enemy" in get_slide_collision(i).collider.name:
	 if Input. is_action_just_pressed("ui_cancel"):

func dead():
is_dead = true
velocity = Vector2(0, 0)
$CollisionShape2D.disabled = true

func _on_Timer_timeout():

 I hope that I can find someone that is kind, and patient enough to help me with this issue, I would do it myself, but like I said I am 16 so I do not have any experience.
:bust_in_silhouette: Reply From: magicalogic

Try using varying jump power then