Electrical – Light fixture wiring issue

electricallightingwiring

So I'm attempting to replace an old light fixture with a new one I got from home depot. The light fixture is at the top of a stairway, there is a switch at the bottom of the stairs as well as the top of the stairs that control the light. Going into the overhead box there are 3 pairs of black/white/ground wires. Only on black wire is hot, every other wire has no voltage. Between the two switches are a set of black/white/red/ground wires. The circuit that the light is on also goes to a small bathroom upstairs as well as a bedroom. How should I proceed wiring this?
I'll attach a few pictures to this to hopefully better clarify what i'm looking at.

enter image description here

enter image description here

enter image description here

Best Answer

New junction box, eh? First, reinstall all cables in the junction box.

That trick with the ground wire wrapped around the sheath appears to be using the cable clamp to ground to the metal box. Note the metal box will have a #10-32 tapped hole intended for a ground screw, and you can put a pigtail on that to ground anything else.

Now, identify which cable goes to the switch. Mark its white wire with black tape, and its black wire with red tape.

Also mark the black wire from the new lamp with red tape.

Now you join similar colors: red to red, black to black, white to white, bare/green to bare/green.