double jump won't work pls help

public class doublejump : MonoBehaviour
{

    private Rigidbody2D rb2d;
    public float jumpower;
    public bool isgrounded;
    public Transform groundcheck;
    public float groundcheckradius;
    public LayerMask whatisground;
    public bool candoublejump;

    void Start()
    {
        rb2d = GetComponent<Rigidbody2D>();
        
    }
   void jump()
   {
   rb2d.velocity = new Vector2(rb2d.velocity.x, jumpower);
   }
    
    void Update()
    {
       if (Input.GetKey(KeyCode.Space)) 
        {
         if(isgrounded)
         {
         jump();
         candoublejump = true; 
         }
         else if(candoublejump)
         { 
         jump(); 
         candoublejump = false;
         }       
        
        }    
            
        
    }
   private void FixedUpdate()
    {
        isgrounded = Physics2D.OverlapCircle(groundcheck.position,groundcheckradius,whatisground);
       
    }
    private void OnDrawGizmos()
    {
       Gizmos.DrawWireSphere(groundcheck.position, groundcheckradius); 
    } 
   
}

i think it’s because you are using GetKey
and it jumps 2 times at the moment,you should use GetKeyDown :slight_smile: