What is music? And are you sure music is correctly indexed? The error means that you likely referred to music as workspace. Make sure your variables refer to their correct locations. Also where are you playing this from?
If you’re playing it from the catalog, and I assume grabbing their Ids, they always a chance that they’ll fail to load. However, the issue seems to what you’re referring to (in this case ‘music’) is actually workspace. If your script is in workspace, and you’re referring to script.Parent, then music would be workspace itself?
local sound = yourSoundParent
sound.Parent = whereverYouWannaParent
local soundId = {
"soundid";
"soundid";
"soundid";
"soundid";
}
while true do
for i = 1, #soundId do
sound.SoundId = "rbxassetid"..soundId[i]
sound:Play()
sound.Ended:Wait()
end
end
Try to make a list with all your sound and using for loop with repeat until like this script i just created
local sound = {2696216972, 1347686578,485221165, 4496252615}
local musicPlayer = script.Parent
while true do
for i in pairs(sound) do
musicPlayer.SoundId = "rbxassetid://"..sound[i]
musicPlayer:Play()
print("Playing ".. sound[i])
repeat wait (1) until not musicPlayer.IsPlaying
print("ended")
end
end
A sound object:
I was under the impression that ‘music’ was a sound object, and you were plugging in the sound ID’s into the sound objects soundID and playing it. Yes, I believe you would need a sound object to play the sound.
I didn’t want this to drag on forever, so I’ll clarify a few things. In order to play a sound, you need a sound object. You can set the SoundId via your code, without doing it manually.
local music = script.Sound -- Your sound object
music.SoundId = "rbxassetid://"..sound1-- Boom, you set the soundId and now you can play it
Okay, my question is, how do i put all of the IDs into one sound object? Sorry if i seem dumb, just that i only saw one Sound ID spot. Should i just copy paste all of them into the sound ID?
Fixed the code above a little so its checking for when the audio stops to start a new song.
Not sure if it is more optimized but it does not contain a repeat wait timer.
My apologies for bumping the thread but this was one of the first results on Google and I know more people are looking for a music player system.
local sound = {2696216972, 1347686578,485221165, 4496252615}
local musicPlayer = script.Parent.Sound
while true do
for i in pairs(sound) do
musicPlayer.SoundId = "rbxassetid://"..sound[i]
musicPlayer:Play()
print("Playing ".. sound[i])
musicPlayer.Ended:Wait()
print("ended")
end
end