Raycast not working.

This is my code:

 void jump()
    {

        //+hit.collider.gameObject.name
        

        if (Physics2D.Raycast(groundCheck.position, Vector2.down))
        {
            //Debug.Log("RAYCAST");
            
            if (Input.GetKeyDown(KeyCode.Space) && !isJumped)
            {
                
                myBody.AddForce(new Vector3(0, 250f, 0));
                
            }
            
        }
        
    }```

When I run this code the raycast detects collision on the platform and now checks for when the user hits the space key, when I hit the space key the player jumps but while the player is now in the air the raycast still detects collision with the platform. also if I start the player some distance above the platform, even before the player falls on the platform I can still hit the space key to continue jumping essentially allowing the player to fly. What am I doing wrong? if I try to set a distance for the raycast it won't detect collision with the platform at all.,Here's the code:```
 void jump()
    {

        //+hit.collider.gameObject.name
        

        if (Physics2D.Raycast(groundCheck.position, Vector2.down))
        {
            //Debug.Log("RAYCAST");
            
            if (Input.GetKeyDown(KeyCode.Space) && !isJumped)
            {
                
                myBody.AddForce(new Vector3(0, 250f, 0));
                
            }
            
        }
        
    }

The Raycast is suppose to detect when the player is on the ground. if he’s on the ground the code should be checking if the user hits the space button. When I run this I can hit the Space key to jump but when the player is in the air the raycast is still detecting collision. What am I doing wrong? if I try to set the distance of the Raycast it never detects collision at all, even if I set it to something ridiculous like 1000f.

Sorry I don’t know why but it added my first attempt to ask this question. I don’t know why