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

Is there a way to make this play after the player dies too?

I created this so the players could listen to music for a game I made but when the player dies.... The music stops. Probably due to the fact that the whole player was reset and the fact that the playergui area was reset so the music does not exist. Is there anyway to make this work when the player dies as well?

game.Players.PlayerAdded:connect(function(player)
wait(1)
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=300733201"
sound.Parent = player.PlayerGui
sound:Play()
sound.Looped = true
wait(70)
sound.Looped = false
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=170691997"
sound.Parent = player.PlayerGui
sound:Play()
sound.Looped = true
wait(50)
sound.Looped = false
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=262085924"
sound.Parent = player.PlayerGui
sound:Play()
sound.Looped = true
end)

1 answer

✓ Accepted answer

So all you have to do is use the died event. You are just a few lines away from your solution


game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
wait(1)
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=300733201"
sound.Parent = player.PlayerGui
sound:Play()
sound.Looped = true
wait(70)
sound.Looped = false
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=170691997"
sound.Parent = player.PlayerGui
sound:Play()
sound.Looped = true
wait(50)
sound.Looped = false
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=262085924"
sound.Parent = player.PlayerGui
sound:Play()
sound.Looped = true

	end)

end)

So what i did was add the character added event so it fires whenever a character is added to the player AKA when they re spawn.

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