if the sky is cloudy the sailors will not be able to see the stars but the compass does not need the sky to be clear to tell the direction you are going.
a compass uses magnets to tell someone their direction because the north end attracts to the north pole pointing you north