If you're using yuuutu engine:
In the playMusic Room Start Event:
if (BGM!=0) { if !sound_isplaying(BGM) { sound_loop(BGM) } }
BGM != 0 is for the case where the BGM isn't set and you try to play a sound that doesnt exists. (Forgot to set BGM = sound in Creation Code)
sound_isplaying checks if BGM is playing and if it is, it returns true. The "!" infront of it inverts this so if sound_isplaying returns true, it's false and if sound_isplaying returns false, it is true instead. Basically it inverts true/false. (if BGM is not an actual sound the function will always return false)
sound_loop plays BGM on a loop continuing forever. The code previous to this prevents multiple loops of the same sound from playing.
In the creation code (this is set in the room) make BGM = <background music you want to loop>