Ad
Log in to vote
0

Help! Random music in game play list not working! What can I do to fix this? There are no errors.

Asked by 17 days ago
Edited 17 days ago

Why won't this work? It only prints the first one.

wait(1)
print("Script has started!")
while true do
    local Sounds = script.GetChildren()
    local Random = math.random(1,#Sounds)
    local RandomSound = Sounds[Random]
    print(RandomSound)
    workspace.CurrentPlaylist.SurfaceGui.TextLabel.Text = "Currently Playing: "..RandomSound
    RandomSound:Play()
    wait(RandomSound.TimeLength)
end

Images: https://i.gyazo.com/8e0facb3659c961e6bb8145827ccfdd5.png https://i.gyazo.com/18e3098d81bf2ec4f421e43776b4a17e.png

1 answer

Log in to vote
1
Answered by
SuperPuiu 344 Moderation Voter
17 days ago
wait(1) 
print("Script has started!") 
while true do

 local Sounds = script:GetChildren() -- here was the problem

local Random = math.random(1,#Sounds) 

local RandomSound = Sounds[Random] 

print(RandomSound) workspace.CurrentPlaylist.SurfaceGui.TextLabel.Text = "Currently Playing: "..RandomSound 

RandomSound:Play() 

wait(RandomSound.TimeLength) 

end
Ad

Answer this question