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

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

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

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

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