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:

1game.Workspace.sound1.IsPaused = true

if you want to stop it:

1game.Workspace.sound1:Stop()

EDIT:

1local soundtable = ("Sound1", "Sound2", "Sound3", "Sound4", "Sound5")
2   while i = 1, 2, 3, 4, 5 in pairs (#soundtable) do --[[I've never worked with pairs before.]]
3 if i.IsPlaying == true then
4   i:Stop()
5   wait(0.1)
6   I:Play()
7   end
8   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
01sound1 = --path to a sound
02sound2 = --path to another sound
03 
04while true do
05    sound1:Play()
06    wait(15) --gives the first sound 15 seconds before changing
07    if sound1.IsPlaying == true then
08        sound1.IsPaused = true
09        wait()
10        sound2:Play()
11    else
12        wait()
13    end
14end
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