This is a very simple thing that frustrates me to no end that I can’t figure out.
I have a random music script. Pretty straightforward, literally just, pick a song from a list and play it. I don’t even have any player input to it. I have a virtually identical script in another game that works just fine.
This is the script
local songs =
{535308988,
3169451873,
2499949849,
2406297887,
465492273,
852428251,
197722393,
1495400641,
427662890,
225497763,
535308988,
786465393}
local music = script.Parent
while true do
local play = songs[math.random(1,#songs)]
music.SoundId = "rbxassetid://"..play
music:Play()
music.Ended:Wait(1)
end
What happens is I get in game, a random song plays, it loads the next song id into the sound thing, and then just doesn’t play. I don’t know what’s going wrong please save me
Pretty sure you have to make a new sound object every time you use the :Play() function. Make sure to create it each time, then destroy when ended.
2 Likes
I swear sound playing after 1 is finished keeps breaking over and over again
An alternate would be to just create a new Sound Instance, delete it after it ends, then clone a new one to set it that way:
local songs =
{535308988,
3169451873,
2499949849,
2406297887,
465492273,
852428251,
197722393,
1495400641,
427662890,
225497763,
535308988,
786465393}
while true do
local music = Instance.new("Sound")
music.Parent = workspace --Or parent this to where your music object is
local ID = songs[math.random(1,#songs)]
music.SoundId = "rbxassetid://"..ID
music:Play()
music.Ended:Wait()
music:Destroy()
end
2 Likes
Yep, this worked lmao. I didn’t have to do that before why do it happen now :,)))))) Thanks roblox.
Anyways thank you for ur help!!!
1 Like