To review the color codes:
- Green, yellow/green, or bare are grounds.
- white or gray are neutral, but if the wire is in a cable, it can be used as a hot if it is re-marked with paint or tape. Many people forget the marking, but don't do it.
- every other native wire color can only be used for hot.
Your lamp needs genuine neutral. Attaching it’s white wire to a hot will not work. If it does work, it's because something really weird has happened, like putting it in series with another light. Fix that.
You have a big problem with "box fill"
In the octagon box, I see four /3 cables and two /2 cables terminating there. (The /3 cables are round-ish with twisted wires). That is 4x3 + 2x2 conductors, or 16. All the grounds together are counted as 1 wire. You also need to allocate 1 “wire” for all the cable clamps. That adds up to 18.
#14 wire must be given 2 cubic inches per wire. #12 wire needs 2.25 cubic inches. So I count 36 cubic inches that you need.
A common 1-1/2” deep octagon box is 15.5 cubic inches. A deep octagon box is 21.5. So you need, at the least, one octagon box extension to give you the cubic inches you need. There's no credit for shortening wires, so don't nip off wires to "make room". In fact you need the length to clear the now-taller box.
Likewise the switch box has issues there too. That kind of deep steel 1-gang box is typically 18 cubic inches, or nine #14 wires. A device like a switch or outlet takes 2 “wires", all grounds take 1 and all clamps take 1, so that leaves only 5 actual conductor wires allowable in that box. Fortunately, pigtails are free.
The easiest way to add cubic inches to a switch box is with a Legrand Wiremold "surface conduit starter kit".