Complex sentence: Sting has the magical ability to detect orcs or goblins nearby, glowing blue in their presence, as it did when the Fellowship encountered orcs in the mines of Moria.
Split into simpler sentences: Sting has the magical ability to detect orcs or goblins nearby, glowing blue in their presence. When orcs or goblins were present, it glowed blue, as it did when the Fellowship encountered orcs in the mines of Moria.