Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a sound ID play randomly from a table?

-- I put this stuff here to show just where the Sound is located

Song = Instance.new("Sound")
Song.Parent = Workspace.Bucket
Song.Volume = 100
Song.Looped = false

-- Here's the Assets table

Assets = {143550410,142544487,154072002,150558724,147096633,143620887,148263609,142851579,154237445,142991813,152318857,142301307,157890927,144803449,148324182,146541462,160535179,154741433,142856192,162596497,144003396,144195439,145546010,152536688,162660508,145143628,146058363,148567163,142318459,163404486}
for _, asset in ipairs(Assets) do
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
end

-- Here's the actual part that needs work

Song.SoundId = Assets[math.random(1,#Assets)]
Song:Play()

What do I need to do to get this working? I want this to play a song randomly.

1 answer

✓ Accepted answer

You were missing the asset for playing the sound. This is what it should look like.

Song.SoundId = "rbxassetid://" ..Assets[math.random(1,#Assets)] --'http://www.roblox.com/asset/?id=' can also be used.

2 comments

0

Oh der, thanks man!

0

No problem! Make sure to accept the answer on the side.

This discussion is preserved as it was. New answers, comments, and votes are closed.