I found a problem while trying to replace a ceiling light fixture, but I'm not sure how to fix it. The old fixture worked, but when I put the new fixture on it wouldn't work. If I put a voltage detector on the hot wire, sometimes it confirms the wire is live but sometimes it doesn't (50/50 at best). If I touch the voltage detector to the electrical box, about 75% of the time it shows as live, but every now and then it doesn't detect a live circuit.

Any ideas as to what exactly is wrong? The wiring is probably 30+ years old and is in a vaulted ceiling, so I don't have attic access to the wiring. And I don't want to install the new light fixture on a line that isn't consistently showing a live circuit.

Thanks for any help you can offer!!