My Dash isnt working and i just cant fix it :(,My problem is, that my dash does only work sometimes, and i just cant fix it

//Dash
if (dashTime == -1)
{

        if (playercoin.points >= 1 && Input.GetKeyDown("space"))
        {

            if (z == 1 && x == 0)
            {

                rb.velocity = Vector3.forward * dashSpeed;
                dashTime = startdashTime;
                playercoin.points--;
                dashp.enableEmission = true;
                dashp.Play();
                Ability.fillAmount = 0;

            }
             if (z == -1 && x == 0)
            {
                rb.velocity = Vector3.back * dashSpeed;
                dashTime = startdashTime;
                playercoin.points--;
                dashp.enableEmission = true;
                dashp.Play();
                Ability.fillAmount = 0;
            }
             if (z == 0 && x == -1)
            {
                rb.velocity = Vector3.left * dashSpeed;
                dashTime = startdashTime;
                playercoin.points--;
                dashp.enableEmission = true;
                dashp.Play();
                Ability.fillAmount = 0;
            }
            if (z == 0 && x == 1)
            {
                rb.velocity = Vector3.right * dashSpeed;
                dashTime = startdashTime;
                playercoin.points--;
                dashp.enableEmission = true;
                dashp.Play();
                Ability.fillAmount = 0;

            }

        }
    }
    else
    {

        rb.velocity = Vector2.zero;
        dashTime -= Time.deltaTime;

        Ability.fillAmount -= 1 / startdashTime * Time.deltaTime;
    }

}

I think it cause by "playercoin.points >= 1 " and all depending it z and x, try to comment it’s,
if you can already with it (comment the lines), you need something for it,


Ill try to help trace your problem.
First try to enable "playercoin.points >= 1 ",
if it can’t, that u should add the value of “playercoin.points” or try see your set of this value. maybe something wrong there.


Then for all depending it z and x, enable it (erase comment),.
if you want to do it, make sure you already push space and the value of z or x already given the value(push the direction), if it can’t the value of direction already change in another place, try to trace it.