Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can my script randomly select songs?

Asked by 8 years ago
Edited 8 years ago

I'm making a script for a club so it plays music but how can I make it choose random songs?

Songs = {"401120618","467369212","399781334","461984143"} 
Sound = Instance.new("Sound",workspace)
    wait(0.1)
    SoundID = (Songs)
    Sound.SoundId = "http://www.roblox.com/asset?id="..SoundID
    Sound:Play()
    wait(115)
    Sound:Stop()

2 answers

Log in to vote
0
Answered by
Etheroit 178
8 years ago

Script

local Songs = {"401120618","467369212","399781334","461984143"}  -- Use local variables
local Sound = Instance.new("Sound",workspace)
wait(0.1)
while true do
    local SoundID = Songs[math.random(1, #Songs)]
    Sound.SoundId = "http://www.roblox.com/asset?id="..SoundID
    Sound:Play()
    wait(Sound.TimeLength)
    Sound:Stop()
end
Ad
Log in to vote
2
Answered by 8 years ago
local songs = {"401120618","467369212","399781334","461984143"}

    local sound = Instance.new("Sound")
    local randmusic = math.random(1,#songs)
    sound.Parent = game.Workspace
    sound.SoundId = "http://www.roblox.com/asset/?id="..songs[randmusic]
    sound:Play()

If this is what you wanted, please vote this up and accept this as an answer. I hope this helped you :)

0
Nope, it did not changed songs it played one song and did not play another ): DjinoKip 78 — 8y
1
You never asked for that tho :/ User#11440 120 — 8y

Answer this question