The problem is that you're taking a random number between 1 and 100 while there are only 23 items in the Assets table.
Try changing the this line:
zig.SoundId = Assets[math.random(1,100)]
To this:
zig.SoundId = Assets[math.random(1,#Assets)]
That automatically makes it adjust to the size of the table.
Edit:
Sorry, I kind of messed up there. The actual problems are somewhere else.
Unfortunately, the IsPlaying property is not actually set to false when the sound has stopped. Instead, you will manually have to enter the duration of each song in seconds, like this:
Assets = {
{161475254, 10},
{89960960, 15},
{152669449, 9}
}
Note that these are examples. The 10, 15 and 9 are examples of the durations of these sounds. You'll need to look them up for yourself.
The second problem is that you can't just set the SoundId directly to the assetId. Instead you'll have to do this:
zig.SoundId = "rbxassetid://" .. assetId
The third problem is that you don't use zig:Play() anywhere. The sound won't play if you don't tell it to play.
Putting all of these together, the solution is the following:
Songs = {
{161475254, 10},
{89960960, 15},
{152669449, 9}
}
zig = script.Parent.MainWall.SurfaceGui.ScrollingFrame.Sound
while true do
local songInfo = Songs[math.random(1, #Songs)]
zig.SoundId = "rbxassetid://" .. songInfo[1]
zig:Play()
wait(songInfo[2])
zig:Stop()
end
2 comments
That really can't be the problem cause I have 100 song ID's on the actual script, I just thought there were to many to put in there
@NotSoNorm I edited the answer to include an actual solution. Sorry for overlooking the actual problem. By the way, I tested a few of the soundIds you put in the example, and some of them seemed to be broken, so I recommend you check that.