This is located in a local script, it's supposed to play a random song from a table when a round starts, then wait 120 seconds, and choose another song. Though, if a player dies it screws up this entire script. Can anyone help me find a way to get this working correctly.
When a round starts, play a song. Wait 120 seconds. Play another song.
local Assets = {131111368, 180416653, 142720946, 143959455, 147680226, 177043702, 176164068, 167059227, 167057292, 166605779, 144249596}
local mapValue = game.Workspace.valHolder.mapValue
local Camera = game.Workspace.CurrentCamera
if mapValue.Value ~= 0 then
if mapValue.Value ~= 10 then
local m = math.random(1, #Assets)
local Music = script:WaitForChild("Music")
Music:Clone().Parent = Camera
Camera:WaitForChild("Music")
for _,v in ipairs(Assets) do
Camera.Music.SoundId = "rbxassetid://" ..Assets[m]
Camera.Music:Play()
end
wait(120)
local n = math.random(1, #Assets)
Camera.Music:Stop()
Camera.Music:Destroy() wait()
Music:Clone().Parent = Camera
Camera:WaitForChild("Music")
for _,v in ipairs(Assets) do
Camera.Music.SoundId = "rbxassetid://" ..Assets[n]
Camera.Music:Play()
end
end
end
