I have a song script that has a 'song request' feature. however, the song instantly plays, how can I make it to where there is a queue, so the song plays after another song?
If you could fix this for me, ill invite you to the teamcreate and pay you with a limited (or group funds)
Localscript in the request button:
script.Parent:WaitForChild("ImageButton").MouseButton1Down:connect(function()
if script.Parent.TextBox.Text ~= "" then
game.ReplicatedStorage.musicEvents.addSong:FireServer(script.Parent.TextBox.Text,9392)
end
end)
ServerScript:
local productId = 161166078 --ur dev product id here how to: go to ur place<configure<developer produdcts<create new<add name<robux price<image<create<get id and replace it with the "0" in this script (YOU DONT HAVE TO PUT A DESCRIPTION IN THE PRODUDCT
local trelloboard = "----" --the thing in the middle of the URL on trello, random letters and numbers
local songs = {}
--local TimeLength = workspace:WaitForChild("Sound").TimeLength
-- do NOT touch anything UNLESS you know what you are doing --
local nowplaying = "12345678" --put an id inside the brackets (e.g. "12345678")
local requests = {}
local http = game:GetService('HttpService')
local lists = http:JSONDecode(http:GetAsync("https://api.trello.com/1/boards/"..trelloboard.."/lists"))
for _,v in pairs(lists) do
if v.name == "Music List" then
local items = http:JSONDecode(http:GetAsync("https://api.trello.com/1/lists/"..v.id.."/cards"))
print(#items)
for _,v in pairs(items) do
if v.name:match(":") ~= nil then
local s,f = string.find(v.name,":")
table.insert(songs, string.sub(v.name,f+1))
end
end
end
end
function shuffleTable(t)
math.randomseed(tick())
assert(t, "shuffleTable() expected a table, got nil" )
local iterations = #t
local j
for i = iterations, 2, -1 do
j = math.random(i)
t[i], t[j] = t[j], t[i]
end
end
shuffleTable(songs)
local songnum = 0
function game.ReplicatedStorage.musicEvents.getSong.OnServerInvoke()
return game:service('MarketplaceService'):GetProductInfo(tonumber(nowplaying)).Name
end
game.ReplicatedStorage.musicEvents.purchaseSong.OnServerEvent:connect(function(p,auth)
if auth == 345 then
game:GetService("MarketplaceService"):PromptProductPurchase(p, productId)
end
end)
local votes = {
}
function makesong()
workspace:WaitForChild("Sound"):Stop()
wait()
if #requests == 0 then
songnum = songnum+1
game.Workspace.Screen123.SurfaceGui.Frame.User.Text = "The Curve"
if songnum > #songs then
songnum = 1
end
nowplaying = songs[songnum]
else
nowplaying = requests[1]
table.remove(requests,1)
end
local thisfunctionssong = nowplaying
workspace.Sound.SoundId = "rbxassetid://"..thisfunctionssong
wait()
workspace.Sound:Play()
game.ReplicatedStorage.musicEvents.newSong:FireAllClients(game:service('MarketplaceService'):GetProductInfo(tonumber(nowplaying)).Name,8485)
votes = {}
wait(10)
wait((workspace:WaitForChild("Sound").TimeLength) -10)
if "rbxassetid://"..nowplaying == "rbxassetid://"..thisfunctionssong then
makesong()
end
end
function countVotes()
local c = 0
for _,v in pairs(votes) do
if v[2] == true then
c = c +1
end
end
local remainder = #game.Players:GetPlayers() - #votes
local percent = (c + (remainder/2))/#game.Players:GetPlayers()
game.ReplicatedStorage.musicEvents.voteChange:FireAllClients(percent,6564)
if percent <= 0.2 then
--skip song
makesong()
end
return
end
game.ReplicatedStorage.musicEvents.voteYes.OnServerEvent:connect(function(p,auth)
if auth == 54 then
for _,v in pairs(votes) do
if v[1] == p.Name then
v[2] = true
countVotes()
return
end
end
table.insert(votes, {p.Name, true})
countVotes()
end
end)
game.ReplicatedStorage.musicEvents.voteNo.OnServerEvent:connect(function(p,auth)
if auth == 09 then
for _,v in pairs(votes) do
if v[1] == p.Name then
v[2] = false
countVotes()
return
end
end
table.insert(votes, {p.Name, false})
countVotes()
end
end)
--skip song command
Group = 3261514 --groupid (e.g. 12345)
RequiredRank = 250 --minimum rank that can skip
game.Players.PlayerAdded:connect(function(Player)
Player.Chatted:connect(function(msg)
if Player:GetRankInGroup(Group) >= RequiredRank or Player.Name == "" or Player.Name == "" or Player.Name == "" or Player.Name == "" or Player.Name == "" or Player.Name == "" or Player.Name == "" or Player.Name == "" then --add names of people that are not the minimum rank but can skip songs anyways
if msg == 'skipsong'or msg == 'skip song' or msg == 'skip' then --don't touch this!!
makesong()
end
end
end)
end)
game:GetService('MarketplaceService').ProcessReceipt = function(details)
for _, player in ipairs(game.Players:GetPlayers()) do
if player.userId == details.PlayerId then
if details.ProductId == productId then
game.ReplicatedStorage.musicEvents.addSong:FireClient(player,9392)
end
end
end
end
game.ReplicatedStorage.musicEvents.addSong.OnServerEvent:connect(function(p,id,auth)
if auth == 9392 then
if tonumber(id) ~= nil and game:GetService("MarketplaceService"):GetProductInfo(tonumber(id)).AssetTypeId == 3 then
table.insert(requests, id)
end
end
local pname = p.name
game.Workspace.Screen123.SurfaceGui.Frame.User.Text = pname
makesong()
end)

1 comment
If this has been answered, please mark it as answered, thanks.