-
What do you want to achieve? I want a sound system that plays different songs.
-
What is the issue? My script does not work
-
What solutions have you tried so far? This script
script.Parent.Sound.Ended:Connect(function()
local Sounds = {
"rbxassetid://1837848642",
"rbxassetid://1836797203",
"rbxassetid://1840737041",
"rbxassetid://1837871067",
"rbxassetid://1847606521",
"rbxassetid://1845554017",
"rbxassetid://5410086218",
"rbxassetid://1836842889"
}
script.Parent.Sound.SoundId = Sounds[math.random(1,8)]
script.Parent.Sound:Play()
end)

You’re not starting any audio, so the Ended event never fires.
The Mute/unmute Script already does that
script.Parent.Sound:Play()
script.Parent.MouseButton1Click:connect(function()
if script.Parent.Sound.IsPlaying then
script.Parent.Sound:Stop()
script.Parent.AudioOff.Visible = true
script.Parent.AudioOn.Visible = false
script.Parent.TextLabel.Text = "Unmute"
else
script.Parent.Sound:Play()
script.Parent.AudioOff.Visible = false
script.Parent.AudioOn.Visible = true
script.Parent.TextLabel.Text = "Mute"
end
end)
Wait it actually works now! I forgot to make this line:
script.Parent.Sound:Play()
Does the script need to be looped? And with what loop? Please give an example code
It does not need to be looped. You already made a connection that loops itself.
2 Likes