When you first join, it plays random music, which is nice, but if the player doesnt like it, they can skip the music which I added it at the bottom. The thing is it doesn't work. I've tried soundObject.Ended:Wait(), soundObject.Stop(), both doesn't work either.
Where is this script located? It is located in ReplicatedFirst and the sound is parented in the Local Script.
local soundIds = {1178506899, 6549839923, 1271178762} --BlendS, FushqYeah!, Highlight local soundObject = script.Sound local lastMusicId = soundIds[1] while true do local playingMusicId = soundIds[math.random(1, #soundIds)] print(playingMusicId) if playingMusicId == lastMusicId then repeat playingMusicId = soundIds[math.random(1, #soundIds)] wait(1) until playingMusicId~= lastMusicId print(playingMusicId) lastMusicId = playingMusicId else soundObject.SoundId = "rbxassetid://" .. playingMusicId soundObject:Play() soundObject.Ended:Wait() end end local SkipButton = script.Parent.Parent.StarterGui.FiestaGui.Setting.Frame.SkipButton SkipButton.MouseButton1Click:Connect(function() soundObject.Playing = false end)
-- StarterGui basically waits till a player joins the game then clones all of its contents to the PlayerGui located in game.Players[Player.Name].PlayerGui.
2 . Insert a TextButton into the ScreenGui we made.
--This is our SkipButton. When changing the size, make sure it uses only Scale not offset using Scale will resize it for all device's
note: You can rename them because this script won't define them by the name.
3 . Insert a LocalScript into the SkipButton.
4 . Insert a Sound into the script just like how you did it.
Inside of the LocalScript:
local skipButton = script.Parent local soundObj = script.Sound local soundIds = {1178506899, 6549839923, 1271178762} local currentSongId = nil local function randomSong() while true do local randomSongId = soundIds[math.random(1,#soundIds)] if randomSongId ~= currentSongId or currentSongId == nil then soundObj.SoundId = "rbxassetid://" .. randomSongId soundObj:Play() currentSongId = randomSongId soundObj.Ended:Wait() end end end skipButton.MouseButton1Click:Connect(randomSong) randomSong()
more songs make it more random
something just ticked in my head and it seems that it does more than the last code and it's shorter
if you want to copy and paste the script just hover your mouse over my code and you should see view source in the top right corner