So I have a script in my game that has a "you died" GUI. It used to only play when you fall off the map and hit a killbrick, but now that Iearned about the 'died' event It play the GUI whenever you die.
The problem is the script needs to stop the music playing, then replaying it.
This works in the first level, but not in the others because it has different music
I know there's the property 'IsPlaying' in the sounds, but I don't know how to incorporate that into stopping "current song"
If you want to pause it:
game.Workspace.sound1.IsPaused = true
if you want to stop it:
game.Workspace.sound1:Stop()
EDIT:
local soundtable = ("Sound1", "Sound2", "Sound3", "Sound4", "Sound5") while i = 1, 2, 3, 4, 5 in pairs (#soundtable) do --[[I've never worked with pairs before.]] if i.IsPlaying == true then i:Stop() wait(0.1) I:Play() end endI am not completely sure about this code, but if it gives you any errors, please tell me what they say!
sound1 = --path to a sound sound2 = --path to another sound while true do sound1:Play() wait(15) --gives the first sound 15 seconds before changing if sound1.IsPlaying == true then sound1.IsPaused = true wait() sound2:Play() else wait() end end
I Do It Like This:
To Pause:
game.Workspace.Sound:Play()
wait (5.0)
game.Workspace.Sound:Pause()
To Stop:
game.Workspace.Sound:Play()
wait (5.0)
game.Workspace.Sound:Stop()