Scripting Helpers is winding down operations and is now read-only. More info→
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 1 year ago
Edited 1 year 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 497 Moderation Voter
1 year 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