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

math.random song picker only picking 1 song everytime?

Asked by 7 years ago
Edited 7 years ago

So, I'm trying to make a random song picker for intermission and it stays the same everytime. I even used

math.randomseed(tick())

And it still picks only one song so, whats wrong? Script in ServerScriptService

while true do
    math.randomseed(tick()) 
    INTERMISSION_TIME = 45 --How long intermission is
    PLAY_TIME = 15 --How long people play for
    local songs = game.ServerStorage.Songs
    local songList = songs:GetChildren()    
    local randomSong = math.random(1, #songList)
    songs[randomSong]:Play()
    print(songs[randomSong].Name)
    wait(INTERMISSION_TIME)
    songs[randomSong]:Stop()
    wait(PLAY_TIME)
end

The songs are in serverstorage in a folder, each named 1,2,3 you get the idea. Each time it prints 3 and plays the third song.

1 answer

Log in to vote
0
Answered by
ikiled 75 Donator
7 years ago
while true do
    math.randomseed(tick()) 
    INTERMISSION_TIME = 45 --How long intermission is
    PLAY_TIME = 15 --How long people play for
    local songs = game.ServerStorage.Songs
    local songList = songs:GetChildren()    
    local randomSong = math.random(1, #songList)
    songs[tostring(randomSong)]:Play()
    print(songs[randomSong].Name)
    wait(INTERMISSION_TIME)
    songs[randomSong]:Stop()
    wait(PLAY_TIME)
end

Ad

Answer this question