Sphere cast question.

ok so ive tested this with a raycast and it works just fine but in an attempt to make the raycast bigger i switched to trying to use a spherecast after doing some studying i configured the script as follows but its not working. im guessing i have the syntax wrong or something but whats suppose to happen is that a spherecast happens forward from the player and if the target is in range damange is achieved. however i am not even receiving the print message so i know its not hitting anything.

    void enemyisinrage()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (hastarget == true && GetComponent<Battler>().timerstart == true)
            {
               
                Vector3 forward = transform.TransformDirection(Vector3.forward);
                RaycastHit hit;
                if (Physics.SphereCast(forward, 4.0f, Vector3.forward, out hit, Mathf.Infinity))
                {
                    target.GetComponent<Battler>().takedamage(attackDamage);
                    target.GetComponent<EnemyControl>().takedamage(attackDamage);
                    print("there is something infront of the object");
                }
            }
        }

    }

Try putting some breakpoints into the method and attach the debugger to inspect the values and flow of the method. See Scripting - Community Posts - Unity Learn if you’re using monodevelop or Get Started with Visual Studio and Unity - Unity Learn if you’re using visual studio.

Thanks ill have a look at those but im mostly wondering if i have everything set up correctly