I made GUI music button. but for some reason it won't work.
script.gui.TextButton.MouseButton1Click:connect(function() --code here end)
math.randomseed(tick())
math.random() -- throw out first not-very-random value (known limitation of lua)
musicTable = --Making a table of music / your songs
{
"rbxassetid://142305080", -- 1 - Let's Groove
"rbxassetid://142386715", -- 2 - Can't Touch This
"rbxassetid://276873987", -- 3 - Noob Song
"rbxassetid://1100823134", -- 4 - At Dawn
"rbxassetid://142352014" -- 5 Safety Dance
}
while true do
--Shuffle
local index = math.random(1, #musicTable - 1) -- choose an item not from the end
musicTable[1], musicTable[index] = musicTable[index], musicTable[1] -- switch with first item
for i = 2, #musicTable-1 do -- do regular shuffle algorithm starting at 2nd item
index = math.random(i, #musicTable)
musicTable[i], musicTable[index] = musicTable[index], musicTable[i]
end
--Play music
for i = 1, #musicTable do
wait(1) -- Just creating a small pause before a random song plays
script.Parent.SoundId = musicTable[i] --Choose song
script.Parent:Play() --Play song
script.Parent.Ended:wait() -- Waiting until the song has finished
end
end
Is there something wrong with this script?

5 comments
I would help, but I'm not completely sure why you're trying to shuffle the actual musicTable when you can just use selection = musicTable[math.random(1, #musicTable)]
Because then the same songs would sometimes be played twice.
I don't think the Gui should be parented to the script. It should be parented to StarterGui.
It isn't parented to the script, it's parented to the seat of when you sit, a GUI appears.
How can I make so when I sit, a GUI appears that has button where I can click the music?