I have a problem with my double jump system. I want it to work so if you didn't jump on a platform before double jumping, you can't double jump. I have failed horribly over 2 days to make it work and would be extremely happy if you could tell me how I could solve my problem.
Here is the code:

 func _physics_process(delta):
        if !is_on_floor():
	        coyote_time()
	        velocity.y += gravity * delta

        if is_on_floor():
	        if jumpWasPressed:
		        velocity.y = JUMP_VELOCITY
	        jumpAfterLeavingPlatform = true


        if Input.is_action_just_pressed("up"):
	        jumpWasPressed = true
	        remember_jump_time()
	        anim.play("Flap")
	        if Global.pickup == 1:
		        canDoubleJump = true
	        if jumpAfterLeavingPlatform == true:
		        velocity.y = JUMP_VELOCITY

        if Input.is_action_just_pressed("up") and !is_on_floor() and canDoubleJump and !Global.pickupTimer:
	        anim.play("Flap")
	        velocity.y = JUMP_VELOCITY
	        Global.pickupTimer = true
	        canDoubleJump = false
  • Introduce a jump counter that is reset to the max number of midair jumps every time player hops from the flor and decremented for every midair jump:

    const MAX_MIDAIR_JUMPS = 1
    var jump_pool = MAX_MIDAIR_JUMPS
    	
    func _physics_process(delta):
    	if Input.is_action_just_pressed("up"):
    		if is_on_floor():
    			velocity.y = JUMP_VELOCITY
    			jump_pool = MAX_MIDAIR_JUMPS
    		elif jump_pool > 0: 
    			velocity.y = JUMP_VELOCITY
    			jump_pool -= 1
    			
    	velocity.y += gravity * delta

Introduce a jump counter that is reset to the max number of midair jumps every time player hops from the flor and decremented for every midair jump:

const MAX_MIDAIR_JUMPS = 1
var jump_pool = MAX_MIDAIR_JUMPS
	
func _physics_process(delta):
	if Input.is_action_just_pressed("up"):
		if is_on_floor():
			velocity.y = JUMP_VELOCITY
			jump_pool = MAX_MIDAIR_JUMPS
		elif jump_pool > 0: 
			velocity.y = JUMP_VELOCITY
			jump_pool -= 1
			
	velocity.y += gravity * delta

    xyz Thank you! It didn't work at first but I managed to change it up a bit and it worked perfectly.