Instantiating a gameObject

hello i’m trying to get NPCs to instantiate and use raycast to check if they are in a suitable position for instantiating for some reason unity dosnt let me use a raycast to find out if the object was instantiated above my desired object(a road grid).
UPDATE:
i’ve solved that problem (just needed to convert to (GameObject) i forgot to do that) but now it just dosnt want to recognise my road grid no matter what method i use to find it. name collider name hashID i’m all out of ideas. PLEASE HELP…

 public GameObject NPCs;
    	public float NumOfNPCs;
    	void Awake()
    	{
    		for(int i=0;i<NumOfNPCs;i++)
    		{
    		bool OnRoad = false;
           while(!OnRoad)
    		{
    		Vector3 RandomPos = new Vector3 (Random.Range(-0.0f,70.0f), 0.41187f,Random.Range(0.0f,57.0f));
    		GameObject FreshNPC=(GameObject)Instantiate(NPCs,RandomPos,new Quaternion(0,0,0,0));
    	    FreshNPC.AddComponent<CapsuleCollider>();
    		RaycastHit hit;
    		Ray RoadCheck = new Ray (RandomPos, Vector3.down);
    		FreshNPC.collider.Raycast(RoadCheck, out hit,1.0f);
    		if (hit.collider.name=="PQ_Road")
    				{OnRoad=true;}
    		else
    				{OnRoad=false;}
    		}
    	}
    
    	}

I believe you need to check something like this :

if (Physics.Raycast(ray, out hit))
        {
            if (hit.collider.name == "name)

            {

I am not sure but thats all ive got