I'm making this song system for my game and i made a gui that randomly selects one of the songs in the folders in the gui, so how would i play the selected song?
-- The songs are in the folder which the script in the gui selects.
-- Script in the gui
local Player = game.Players.LocalPlayer
Songs = script["Music"]:GetChildren()
Selected = nil
MTL = .25
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function Song()
Random = Songs[math.random(1,#Songs)]
Selected = Random
script.Parent.Playing.Playing.Text = Selected.Name
wait()
for i = 1,#Selected:GetChildren(),1 do
Selected:GetChildren()[i]:Play()
wait(Selected:GetChildren()[i].Duration.Value-MTL)
end
end
while true do Song() end
Player.Character.Humanoid.Died:connect(function()
for Index,A in pairs(Selected:GetChildren()) do
if A:IsA("Sound") then
A:stop()
end
end
end)

5 comments
Can you please put it into the code block to make it easier to reat
Thats better, let me check it out!
Oh by the way it does say the selected one will play but it doesnt no errors pop up and it doesnt play in game.
Sorry if you misunderstood my explanation before i was trying to say it just wouldnt play.
please address your presentation, if you want to progress to a comprehensive level or wish to work with teams in the future, you won't get far with presentation like this. I appreciate that it can be hard to learn by your own means, but it will benefit you and others in the future.