Ok, so first off, this can be solved through a single function and the use of an 'if' statement.
What you're currently doing is connecting a function to the click detector's MouseClick event, and then connecting another, separate function to the same event. This means that both functions will run every time you click on the object. They will both stop the sound under the Humanoid, but one will play the sound BOOM and the other will stop it, so I really have no idea what actually happens when you run this.
Also, I'm not sure why you're making this toggle a sound in the StarterPlayer.
The code below is a suggestion on how you could solve this. I'm assuming that you wish to turn off a sound in the Humanoid of the player's current character based on your description, so I changed that line as well, but if that's really not what you wanted you can change it back.
01 | local clickdetector = script.Parent:WaitForChild( "ClickDetector" ) |
03 | clickdetector.MouseClick:Connect( function () |
04 | if workspace [ "BOOM" ] .Sound.isPlaying = = true then |
05 | workspace [ "BOOM" ] .Sound:Stop() |
06 | game.Players.LocalPlayer.Character.Humanoid.Sound:Stop() |
08 | workspace [ "BOOM" ] .Sound:Play() |
09 | game.Players.LocalPlayer.Character.Humanoid.Sound:Play() |