Raycast do not detect when distance is closer or further than the max distance

title says here is my code

     if (Physics.Raycast(cameraobj.transform.position, cameraobj.transform.forward, out hit,10))
// do stuff

@StelBlotOfficial_Leader ;;;;;It sure wont detect if it farther than the max distance because of how it is created in the first place

You are also saying it is not detecting for closer distances too ,then i think there is a problem with the other part of the code.
please mention what you are trying to do to make others understand and answer your questions