Recently I decided to do my own music system, but I ran into a problem.
When a player turns on the music, dies, goes to settings, and turns it on again - there will be 2 music playing at the same time.
Here’s my script:
button.MouseButton1Click:Connect(function()
if started == false and on == false then
on = true
started = true
randomSound()
button.ImageColor3 = Color3.fromRGB(255, 255, 255)
elseif started == true and on == false then
on = true
game.SoundService[v]:Resume()
button.ImageColor3 = Color3.fromRGB(255, 255, 255)
elseif on == true then
on = false
game.SoundService[v]:Pause()
button.ImageColor3 = Color3.fromRGB(0, 0, 0)
end
end)