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

The music w'ont stop when player died !!! ??

game.Players.PlayerAdded:Connect(function(plr)

	 plr.CharacterAdded:connect(function(char)
        char:WaitForChild("Humanoid").Died:connect(function()
            print(plr.Name.." died!")
			if game.ReplicatedStorage.RandomMusic.Music1.Playing == true then
				game.ReplicatedStorage.RandomMusic.Music1:Stop()
			end
			if game.ReplicatedStorage.RandomMusic.Music2.Playing == true then
				game.ReplicatedStorage.RandomMusic.Music2:Stop()
			end
			if game.ReplicatedStorage.RandomMusic.Music3.Playing == true then
				game.ReplicatedStorage.RandomMusic.Music3:Stop()
			end
			if game.ReplicatedStorage.RandomMusic.Music4.Playing == true then
				game.ReplicatedStorage.RandomMusic.Music4:Stop()
			end
			if game.ReplicatedStorage.RandomMusic.Music5.Playing == true then
				game.ReplicatedStorage.RandomMusic.Music5:Stop()
			end
        end)
    end)
end)


2 comments

0

Not sure what's wrong, but I suggest you use a for loop so you're not repeating yourself so much.

0

You do not stop the music when they spawn you only play the music when the die

1 answer

Use a local script like how I did with mine. Use this code and put in a sound in StarterGui, then insert a LocalScript. This is only if you die.If you reset, the music would start playing from the beginning.

local sound1= 884696085
local music=script.Parent
local sound2= 214902446
local music=script.Parent
local sound3= 225000651
local music=script.Parent
local sound4= 1088486530
local music=script.Parent
local sound5= 515864049
local music=script.Parent
local sound5= 515864049
local music=script.Parent
local sound6= 706817339
local music=script.Parent
local sound7= 515864049
local music=script.Parent

while true do
	wait()	
	music.SoundId="rbxassetid://"..sound1
	music:Play()
	music.Ended:Wait()
	wait()	
	music.SoundId="rbxassetid://"..sound2
	music:Play()
	music.Ended:Wait()
	wait()	
	music.SoundId="rbxassetid://"..sound3
	music:Play()
	music.Ended:Wait()
	wait()	
	music.SoundId="rbxassetid://"..sound4
	music:Play()
	music.Ended:Wait()
	wait()	
	music.SoundId="rbxassetid://"..sound5
	music:Play()
	music.Ended:Wait()
	wait()	
	music.SoundId="rbxassetid://"..sound6
	music:Play()
	music.Ended:Wait()
	wait()	
	music.SoundId="rbxassetid://"..sound7
	music:Play()
	music.Ended:Wait()
end

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