So im trying to make it so a NPC can choose a block in mine, check if it can get to it and then mine to it. However for some reason it still goes for blocks it can not reach. My mine shaft is in a way like for example minecraft.
It looks like the magnitude of your Direction (2nd argument) for Ray.new is too short. Try making it longer. e.g. Ray.new(char.HumanoidRootPart.Position,(x.Position - char.Head.Position).unit*20)
You can also forgo multiplying the unit vector entirely, and do: Ray.new(char.HumanoidrootPart.Position, (x.Position - char.HumanoidRootPart.Position). This will cast a ray directly from the HumanoidRootPart to the ore, because the magnitude of the direction vector will always equal the magnitude of the displacement between the 2 positions. This is a better alternative for your use case.
You could also avoid adding ore to the ignore list, after implementing the previous. If the hit part is not the ore, there is an obstruction; if the ray hits the ore, there is a straight path. This is probably a more reliable method.
You should also make sure that you are consistently using HumanoidRootPart throughout, and not a mixture of that and Head