How do I make a player move using buttons?

Options

Hello, I can't figure out how to move a player using UI buttons. Something as simple as this doesn't work:

    public void Jump()

    {

        if (photonView.IsMine == true)

        {

            rb.velocity = new Vector2 (rb.velocity.x, 5);

        }

    }


but if I don't use buttons it works:

    void Update()

    {

        if (photonView.IsMine == true && Input.GetMouseButtonDown(0))

        {

            rb.velocity = new Vector2(rb.velocity.x, 5);

        }

    }


So if anyone has any ideas please let me know. Thanks :D