Why is my raycast not working?

I have made a character controller script to move my character and enable him to wallrun and it works fine, I tried adding in hookshots from codemonkey’s youtube video (Awesome FPS Hookshot Mechanic! (Unity 3D Tutorial) - YouTube) and my raycasts do not seem to be working or detecting anything, here is the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movement : MonoBehaviour
{
//camera
public float mouseSensitivity = 400f;
float xRotation = 0f;

public Camera camera;

//movement variables
public float speed = 12f;
public CharacterController controller;

//gravity variables
Vector3 velocity;
public float gravity = 9.81f;

//groundcheck variables
public Transform groundcheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
bool isGrounded;

//respawn variables
public Transform playerPosition;
public Vector3 respawnPosition;

//jump variables
public float jumpHeight = 3f;

//sprint variables
bool isSprinting;

//wallrun movement variables
public float wallDistance = 2f;
public LayerMask wallMask;
bool isWallLeft;
bool isWallRight;
public Transform checkWallLeft;
public Transform checkWallRight;
bool jumpFromWall;
bool jumpedFromWallRight;
bool jumpedFromWallLeft;

//walrun camera variables
public float zRotation = 0f;
public float maxWallrunCameraTilt = 25f;

public Transform debugHitpointTransform;

private void Movement(){
    //detecting input
    float xAxisMovement = Input.GetAxis("Horizontal");
    float zAxisMovement = Input.GetAxis("Vertical");

    //using the input to move player
    Vector3 Movement = transform.right * xAxisMovement + transform.forward * zAxisMovement;
    controller.Move(speed * Movement * Time.deltaTime);
    
    //gravity
    velocity.y += gravity * Time.deltaTime;
    controller.Move(velocity * Time.deltaTime);

    //groundcheck
    isGrounded = Physics.CheckSphere(groundcheck.position, groundDistance, groundMask);

    if(isGrounded && velocity.y < 0){
        velocity.y = -2f;
    }

    //jump
    if(Input.GetButtonDown("Jump") && isGrounded){
        velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
    }

    //sprint
    if(Input.GetKeyDown(KeyCode.LeftShift) && isGrounded){
        isSprinting = true;
        speed = 18f;
    }

    if(Input.GetKeyUp(KeyCode.LeftShift)){
        isSprinting = false;
        speed = 12f;
    }

    //respawn
    if(playerPosition.position.y < -20){
        playerPosition.position = respawnPosition;
    }

    if(playerPosition.position.z < -100 && isGrounded){
        respawnPosition = new Vector3(2.5f, 17, -103);
    }
    if(playerPosition.position.z < -157 && isGrounded){
        respawnPosition = new Vector3(2.5f, 24, -160);
    }

    //wallrun movement
    isWallLeft = Physics.CheckSphere(checkWallLeft.position, wallDistance, wallMask);
    isWallRight = Physics.CheckSphere(checkWallRight.position, wallDistance, wallMask);

    if (isWallLeft){
        gravity = -14f;
        speed = 18f;
        if (Input.GetButtonDown("Jump") && jumpedFromWallLeft == false){
            jumpedFromWallLeft = true;
            jumpedFromWallRight = false;
            jumpFromWall = true;
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }
    }
    if (isWallRight){
        gravity = -14f;
        speed = 18f;
        if (Input.GetButtonDown("Jump") && jumpedFromWallRight == false){
            jumpedFromWallRight = true;
            jumpedFromWallLeft = false;
            jumpFromWall = true;
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }
    }
    if(!isWallLeft && !isWallRight){
        if (jumpFromWall == false){
        gravity = -19.62f;
        }
        if (isSprinting == false){
        speed = 12f;
        }
    }

    if (isGrounded){
        jumpFromWall = false;
        jumpedFromWallLeft = false;
        jumpedFromWallRight = false;
    }
}

private void CameraMovement(){
    
    //detecting mouse input
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
    
    //using mouse input for camera
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);
    xRotation -= mouseY;
    camera.transform.localRotation = Quaternion.Euler(xRotation, 0f, zRotation);
    transform.Rotate(Vector3.up * mouseX);

    //wallrun camera movement
    if(Mathf.Abs(zRotation) < maxWallrunCameraTilt && isWallLeft){
        zRotation -= Time.deltaTime * maxWallrunCameraTilt * 2f;
    }

    if(Mathf.Abs(zRotation) < maxWallrunCameraTilt && isWallRight){
        zRotation += Time.deltaTime * maxWallrunCameraTilt * 2f;
    }

    if(!isWallLeft && !isWallRight){
        if(zRotation > 0){
            zRotation -= Time.deltaTime * maxWallrunCameraTilt * 2f;
        }
        if(zRotation < 0){
            zRotation += Time.deltaTime * maxWallrunCameraTilt * 2f;
        }
    }
}

void Start()
{
    //respawn
    respawnPosition = new Vector3(0, 5, 0);
    
    //gravity
    gravity = -19.62f;
    
    //camera
    Cursor.lockState = CursorLockMode.Locked;
    zRotation = 0f;
    
}

// Update is called once per frame
void Update()
{
    Movement();
    HandleHookshotStart();
}

void LateUpdate()
{
    CameraMovement();
}

private void HandleHookshotStart(){
    if (Input.GetKeyDown(KeyCode.E)){
        if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit raycastHit)){
            debugHitpointTransform.position = raycastHit.point;
        }
    }
}

}

Found the Solution! Apparently, the raycast detects the player capsule (which im using, it can be any shape really) as an object, causing it to glitch out as my camera is inside the player capsule, removing the mesh of the player capsule and the mesh renderer completely fixed it and it is now working!!