Raycast can't detect a block that has been created in the same frame, so you have to wait another frame (1÷60 seconds) after creating the object for Raycast to detect it.