However, a conventional compass is useless on Mars. Unlike the Earth, Mars no longer has a global magnetic field.
Would a compass work on another planet?
It depends on the planets internal structure. Compasses on earth work because the earth generates a magnetic field. The exact mechanism is (I believe) still debated but is related to geological processes occurring in the inner and outer core of earth, which are primarily iron.
Why would a compass not work on Mars?
Mars has a very weak, highly spatially variable magnetic field due to remnant magnetisation of some of its crust (from when it did have a field.) A compass would probably flop around and point in random directions.