Your button's outputs will all fire at the same time when the button is damaged. You are playing it and immediately stopping it.
To debug I/O issues in the future, enable
developer 2 in the console.
To fix this issue, the best solution would be to use the
OnIn output to play the music, and
OnOut output to stop it. Then set the button to a toggle type in the spawnflags so when activated it switches between the
In and
Out state. Adjust the
speed and
lip key values to taste, or use the
Don't Move spawnflag if you don't want it to move.
Avoid using
OnDamaged for button activations, and instead use
OnPressed and enable the
Damage Activates spawnflag. The
OnPressed output can be triggered by multiple things, including the player +use key if the server has it enabled, and physical touch from the player if the
Touch Activates spawnflag is enabled. It will also respond to
Use or
Press inputs from other entities, which is convenient.
OnDamaged should be reserved for situations when you want to make the button respond to actual damage; for example by destroying it so it can't be pressed.
Tip: Add outputs to change the colour of the button to indicate its state. e.g. Red for stop and green for start. Give it a white texture like
dev/reflectivity_90b and set its
FX Color keyvalue to green so it spawns in looking 'off and ready'. Then add the following outputs:
OnIn > !self > Color > 255 0 0
OnOut > !self > Color > 0 255 0
When it's pressed in, it will turn red. When it's pressed out, it will turn green.