Awesome! Great feature! Now we just need a pause command!
Use SoundService instead of putting the sounds in Workspace, as SoundService is meant for sounds.
Well, I made a Music System, that’s open-sourced.
But do you want to add a Blacklisted Music, just incase.
Great tutorial!
However, I have a concern with your implementation of those bindable events. In the line below:
if #queue == 0 then script.addSongs:Fire() end
could you not run into possible undefined behavior? The way the code is set-up, the addSongs event will fire as the rest of that current playSong event thread is running. I feel like potentially you could be indexing the queue before it has been refilled. There may be something I’m missing though.
A possible solution to this could be to yield the playSong thread until addSongs has finished executing.
I’m interested to hear your thoughts on this.
Thanks for the suggestion. I don’t really mess around with sound objects a lot. I’ll edit my post.
ROBLOX automatically yields when you fire events I believe. The code below that if statement will run after the function has finished running its code, I’m not entirely sure. Thanks for the reply.
EDIT: I just found out in the developer page that it doesn’t. Thanks for noticing that! A possible way to fix this is to use a BindableFunction instead and simply return any value when the code is done. I do know that BindableFunctions do yield as ROBLOX waits for them to return a value.
It’s if player:GetRankInGroup(000000) >= 5
It doesn’t matter. That’s up to the user writing the script to do. It doesn’t have to be >= 5
Hello! I’m having an error, not sure why. I can’t get the music to play, here is the errors:
I’m kind of a scripting noob so help is greatly appreciated!
I replied in your forum post.
Unfortunately, this is broken, even after the fixes. It stops working after 2 songs. This may have to be re-written.
Are you sure? It works completely fine for me.
Yeah, not sure why, really strange. Play my game, you’ll see the error after a bit.
It happens a lot quicker when I skip as well.
Still doesn’t work, got any idea why? Seems really odd to me.
I think the issue might be the skip script, It doesn’t happen unless I skip songs, then it stops working.
Edit: My bad, I think it’s because I put the skip part after the functions, sorry about that!
Edit2: Still is an issue. After you skip a song, and the song finishes, it stops playing a song. No errors in the console, not sure why this is happening.
Please make a song request for this, I would love you forever!
Thanks for this excellent code. For a strange reason, it only plays the first song. It eventually loads the second song and also executes the Play() method, but you hear nothing. The URI is correct.
I did a quick hack, by creating and destroying the sound object for each song within the script. That seems to work
Thank you so much for this impressive tutorial! Definitely needed this since I’m a beginner programmer.
Ah, beans. Maybe the reason all my games take forever to load is that I imported all the songs as Sound instances, instead of doing it like this…
Here is an updated version to the music player tutorial: Music Player Tutorial - Resources / Community Tutorials - DevForum | Roblox