Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Current Song playing to stop?

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"

1 comment

0

Some code, please?

3 answers

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!

2 comments

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.

0

oh ok, i edited my answer.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.