Looking for metal sensor

I tried using resistor as potential divider. But that didn't work. Somehow it would give 12v at output.

Don't know what you were doing but what ever it was it was not right. A potential divider is a the answer.

I tried different resistors but voltage is always around 12V.

With a single resistor yes it will. A potential divider is two resistors in series and you connect the arduino across the resistor that goes to ground and give it a ground in common with the arduino.

So far no errors.

Have you looked at the signal on a scope? What about the rise time?

If you could tell me the problems that I might encounter using a regulator

The major problems are oscillations, instability, problems with minimum current draw and speed of propagation through the regulator.