Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Current Song playing to stop?

Asked by 10 years ago

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"

0
Some code, please? Redbullusa 1580 — 10y

3 answers

Log in to vote
0
Answered by 10 years ago

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
    end
  

I am not completely sure about this code, but if it gives you any errors, please tell me what they say!

0
That's not what I'm trying to do, I already know all of that. I need a part of a script that checks if any songs are playing, then pauses one and plays another. SpazzMan502 133 — 10y
0
oh ok, i edited my answer. TroytheDestroyer 75 — 10y
Ad
Log in to vote
0
Answered by
Relatch 550 Moderation Voter
10 years ago
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
Log in to vote
0
Answered by 10 years ago

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()

Answer this question