Jumping problem

I have this script that needs to make the sphere jump:

using UnityEngine;
using System.Collections;

public class MoveSphere : MonoBehaviour {

    private float MovementSpeed = 2;
    private bool isFalling = false;
    private float JumpForce = 2;
    public GameObject JumpOnOtherThenWall;
   
    void Update()
    {
        float MoveHorizontal = Input.GetAxis ("Horizontal");
        Vector3 Movement = new Vector2(MoveHorizontal, 0.0f);
        rigidbody.AddForce(-Movement * MovementSpeed);

        //Jump
        if(Input.GetKeyDown (KeyCode.Space) && isFalling == false)
        {
            rigidbody.AddForce(Vector3.up * JumpForce * 100);
        }
        isFalling = true;
    }

    //Jump only if on the ground
    void OnCollisionStay()
    {
        if(JumpOnOtherThenWall.name != "Wall")
        {
            isFalling = false;
        }
    }

}

The problem is that it allows the player to jump even if the player is touching the wall and not the floor, I added the if statement inside the OnCollisionStay() function in order to prevent that but now it’s not jumping at all.

I think its because isFalling is being set to false constantly in the update function, and its overriding the OnCollisionStay function.

It is set to true not false and the only thing that does the problem is the if in the OnCollisionStay, it worked without it but like I said it was possible to jump on walls :confused: