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

How to make music stop repeating when you die?

I don't want the music to repeat when the person dies

MUSIC01 = game.Workspace.AmbientMus01
MUSIC02 = game.Workspace.AmbientMus02
while wait() do
	wait(1)
		MUSIC01:Play()
print("FIRST STARTED")
	wait(118)
		MUSIC01:Stop()
print("DONE")
	wait(2.5)	
		MUSIC02:Play()
print("SECOND STARTED")
	wait(96)	
		MUSIC02:Stop()
print("DONE")
	end

I've tried making a checker but that didn't work i also tried waiting for the character (both times the sound didn't even play) I looked for a property in Humanoid or anywhere else in character and i tried putting it in Workspace and ServerScriptStorage Is there anyway to stop this from restarting?

1 answer

http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Died

Died event is fired when the player dies

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			MUSIC:Pause() --To whatever your music name is
		end)
	end)
end)

http://wiki.roblox.com/index.php?title=API:Class/Sound/Pause

1 comment

0

Why would i want the music to stop though ?? wouldnt i want it to pause and then resume it ?

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