To use a sound from the Roblox library, you use the actually correct way to refer to the sound's id:
http://www.roblox.com/asset/?id=whatevertheidis
To then make the Sound instance play the newly found sound, you would have to stop it and replay it:
workspace.Part.Sound.SoundId = http://www.roblox.com/asset/?id=firstid
workspace.Part.Sound:Play()
wait(5)
workspace.Part.Sound.SoundId = http://www.roblox.com/asset/?id=secondid
wait(2)
workspace.Part.Sound:Stop()
workspace.Part.Sound:Play()
EDIT - The script again doesn't work. Why would that be? Well, StarterGui contents get all sent to each player's PlayerGui. You want to affect that sound which the player gets.
So instead of
game.StarterGui.ScreenGui.Script
You use
script.Parent.Parent.Parent.Parent.Parent.Script
Thus here is the fixed script:
Frame = script.Parent.Parent
Button = script.Parent
Text1 = Frame:WaitForChild("ID")
Music = script.Parent.Parent.Parent.Parent.Parent.Script
Part = Music:WaitForChild("Sound")
a = Frame:WaitForChild("ID")
script.Parent.MouseButton1Click:connect(function()
Part.SoundId = "http://roblox.com/asset/?id=" .. a.Text
Part:Stop()
end)
3 comments
It changes it to the right sound id but it doesnt change the music
Just for reference, combining strings and variables like that is a process called "concatenation" if you ever come across that word at some point
I would recommend making multiple sounds, for each song, so you just have to stop the current one, and play the new one.