I have made a Music System for a ROBLOX group I develop in but cannot for the life of my figure out why some times it just decides to.. stop working.
The system plays songs in our trello until someone pays for a song which is added to the 'PaidToPlay' list and is played next.
Help?
No errors are printed in studio when the sound stops.
I've cut out parts which aren't required - to stop this being used elsewhere.
Server-Side:
local serverTold = false
local MusicList = {}
local PaidToPlay = {}
local PaidPlayer = {}
function playSong()
game.Workspace:WaitForChild("SoroSound"):Stop()
wait()
if #PaidToPlay == 0 then
toPlay = MusicList[math.random(1,#MusicList)]
playerWhoPlayed = "Server"
else
toPlay = PaidToPlay[1]
playerWhoPlayed = PaidPlayer[1]
table.remove(PaidToPlay,1)
table.remove(PaidPlayer,1)
end
local song = toPlay
game.Workspace.SoroSound.SoundId = "rbxassetid://"..song
wait()
game.Workspace.SoroSound:Play()
game.ReplicatedStorage.updateUI:FireAllClients(game:service('MarketplaceService'):GetProductInfo(toPlay).Name,playerWhoPlayed)
wait()
end
game.Lighting.songEnded.OnServerEvent:connect(function()
if serverTold == true then
--Ignore
else
serverTold = true
wait()
playSong()
wait(20)
serverTold = false
end
end)
Client-Handle:
game.ReplicatedStorage.updateUI.OnClientEvent:connect(function(SongName, playedby)
game.Players.LocalPlayer.PlayerGui.SorosUI.Music.Current.Text = "Now Playing: "..SongName.." (Played by "..playedby..")"
end)
game.ReplicatedStorage.purchasedSong.OnClientEvent:connect(function()
script.Parent.SorosUI.GUIs.chooseSong:TweenPosition(UDim2.new(0.5,-150,0.5,-100),"In",0,0.2)
end)
local song = game.Workspace:WaitForChild("SoroSound")
song.Ended:connect(function()
game.Lighting.songEnded:FireServer()
end)
