Replacement motion detector light only works with neutral connected to ground
it turned out to be a loose neutral in a junction box. the second problem was they ran 12/4 from the switch box to the junction box and used the red wire as the second hot wire I'm guessing to save money and be cheap and this was done during construction so that made isolating and troubleshooting it more difficult.