Why does changing the custom material of a part make it undetectable with mouse.Target?

Hello everyone, I hope you are all having a good day.

I was just wondering why when you change a part’s material to a custom material like so:

part.MaterialVariant = "Material1"

That the part is no longer detectable by using mouse.Target, and the detection actually goes through the part and doesn’t detect it at all. At least for me when I tried this in Studio.

Does anyone know how I can detect a part with a custom material without using mouse.Target? Or why this is happening?

Thank you very much.

I am not sure why this is happening but you should be able to do a workaround using raycasts to mimic mouse.Target