I have music system + gui and it has a button you can press that prompts a purchase to buy a song request dev product. Whats supposed to happen is after the purchase is confirmed a localscript fires an event that makes the gui that you input the song id into visible. But instead when you purchase the dev product the gui never becomes visible. The worst part about this though is that it seems to work on my testing game/studio but not on the published game itself and it is very frustrating. Here is the Script in Serverscriptservice that runs the music system:
local productId = 346079951
local Group = 1227426
local RequiredRank = 14
local skipratio = 0.35
local songs = {5084091960,1973091728,2662024151,2324311336,1845094882,4798110815,3796647570,4920228588,4326740145,4841955820,4917266346,3468999118,5024913240,3494695691,4822495701,2053012994,4924408580,3269265418,4492045629,2495351392,2662428554,3458181956,3318010202,2257648420,688743033,4916443370,4822358205,4917266346,3044192264,576369240,695587119,271117387,1271685878,2739129141,5015230842,341597142,4967278397,4822534132,1517320691,2545958785,2926941188,4775169656,4749587176,1305328437,4508857695,2390067986,2604723487,1519561130,4565879548,4294021040,576686419,5019172375,1343224436,3977947504,996149327,}
local nowplaying = nil
local requests = {
}
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()
if nowplaying then
return game:service('MarketplaceService'):GetProductInfo(tonumber(nowplaying)).Name
else
return nil
end
end
game.ReplicatedStorage.musicEvents.purchaseSong.OnServerEvent:connect(function(p)
if p.userId > 0 then
game:GetService("MarketplaceService"):PromptProductPurchase(p, productId)
end
end)
local votes = {
}
function makesong()
workspace:WaitForChild("TrelloSound"):Stop()
wait()
if #requests == 0 then
songnum = songnum+1
if songnum > #songs then
songnum = 1
end
nowplaying = songs[songnum]
else
nowplaying = requests[1]
table.remove(requests,1)
end
local thisfunctionssong = nowplaying
workspace.TrelloSound.SoundId = "rbxassetid://"..thisfunctionssong
wait()
workspace.TrelloSound:Play()
game.ReplicatedStorage.musicEvents.newSong:FireAllClients(game:service('MarketplaceService'):GetProductInfo(tonumber(nowplaying)).Name)
votes = {}
workspace:WaitForChild("TrelloSound").Ended:wait(1)
workspace.TrelloSound.TimePosition = "0"
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)
if percent <= 0.2 then
--skip song
makesong()
end
return
end
game.ReplicatedStorage.musicEvents.voteYes.OnServerEvent:connect(function(p)
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)
game.ReplicatedStorage.musicEvents.voteNo.OnServerEvent:connect(function(p)
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)
game.Players.PlayerAdded:connect(function(Player)
Player.Chatted:connect(function(msg)
if Player.Name == "Dxligent" or Player.Name == "Romero911" or Player.Name == "DesiredDemonz" or Player.Name == "" or Player.Name == "" or Player.Name == "" or Player.Name == "" then
if msg == '!skip' or msg == '!Skip' or msg == '!skipsong' or msg == '!Skipsong' or msg == '!Next' or msg == '!next' or msg == '!Nextsong' or msg == '!nextsong' then
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)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
end
game.ReplicatedStorage.musicEvents.addSong.OnServerEvent:connect(function(p,id)
if tonumber(id) ~= nil and game:GetService("MarketplaceService"):GetProductInfo(tonumber(id)).AssetTypeId == 3 then
table.insert(requests, id)
end
end)
makesong()
And here is the localscript in the gui:
local info = game.ReplicatedStorage.musicEvents.getSong:InvokeServer()
if info ~= nil then
script.Parent.TextLabel.Text = "" .. info
end
game.ReplicatedStorage.musicEvents.newSong.OnClientEvent:connect(function(song)
script.Parent.TextLabel.Text = "" .. song
script.Parent.Frame:TweenSize(UDim2.new(.5,0,1,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, .2, true)
script.Parent.Parent.opt.down.ImageColor3 = Color3.new(1,1,1)
script.Parent.Parent.opt.up.ImageColor3 = Color3.new(1,1,1)
end)
game.ReplicatedStorage.musicEvents.voteChange.OnClientEvent:connect(function(percent)
script.Parent.Frame:TweenSize(UDim2.new(percent,0,1,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, .2, true)
end)
game.ReplicatedStorage.musicEvents.addSong.OnClientEvent:connect(function()
script.Parent.Parent.add.Visible = true
end)
local selected = nil
script.Parent.Parent:WaitForChild("opt"):WaitForChild("up").MouseEnter:connect(function()
if selected ~= script.Parent.Parent.opt.down then
script.Parent.Parent.opt.down.ImageColor3 = Color3.new(1,1,1)
end
script.Parent.Parent.opt.add.ImageColor3 = Color3.new(1,1,1)
if selected ~= script.Parent.Parent.opt.up then
spawn(function()
for i=1,10 do
script.Parent.Parent.opt.up.ImageColor3 = Color3.new(1 - (i*.1),1-((8.5*i)/255),1 - (i*.1))
wait()
end
end)
end
end)
script.Parent.Parent.opt.up.MouseLeave:connect(function()
if selected ~= script.Parent.Parent.opt.up then
script.Parent.Parent.opt.up.ImageColor3 = Color3.new(1,1,1)
end
end)
script.Parent.Parent.opt:WaitForChild("down").MouseEnter:connect(function()
if selected ~= script.Parent.Parent.opt.up then
script.Parent.Parent.opt.up.ImageColor3 = Color3.new(1,1,1)
end
script.Parent.Parent.opt.add.ImageColor3 = Color3.new(1,1,1)
if selected ~= script.Parent.Parent.opt.down then
spawn(function()
for i=1,10 do
script.Parent.Parent.opt.down.ImageColor3 = Color3.new(1,1 - (i*.1),1 - (i*.1))
wait()
end
end)
end
end)
script.Parent.Parent.opt.down.MouseLeave:connect(function()
if selected ~= script.Parent.Parent.opt.down then
script.Parent.Parent.opt.down.ImageColor3 = Color3.new(1,1,1)
end
end)
script.Parent.Parent.opt:WaitForChild("add").MouseEnter:connect(function()
if selected ~= script.Parent.Parent.opt.up then
script.Parent.Parent.opt.up.ImageColor3 = Color3.new(1,1,1)
end
if selected ~= script.Parent.Parent.opt.down then
script.Parent.Parent.opt.down.ImageColor3 = Color3.new(1,1,1)
end
spawn(function()
for i=1,10 do
wait()
end
end)
end)
script.Parent.Parent.opt.add.MouseLeave:connect(function()
script.Parent.Parent.opt.add.ImageColor3 = Color3.new(1,1,1)
end)
script.Parent.Parent.opt.add.MouseButton1Down:connect(function()
if script.Parent.Parent.add.Visible == false then
script.Parent.Parent.opt.add.ImageColor3 = Color3.new(1,1,1)
game.ReplicatedStorage.musicEvents.purchaseSong:FireServer()
end
end)
script.Parent.Parent.opt.up.MouseButton1Down:connect(function()
game.ReplicatedStorage.musicEvents.voteYes:FireServer()
selected = script.Parent.Parent.opt.up
script.Parent.Parent.opt.up.ImageColor3 = Color3.new(0, 170/255, 0)
end)
script.Parent.Parent.opt.down.MouseButton1Down:connect(function()
game.ReplicatedStorage.musicEvents.voteNo:FireServer()
selected = script.Parent.Parent.opt.down
script.Parent.Parent.opt.down.ImageColor3 = Color3.new(1,0,0)
end)
warn("Music player by xDiggie5K")
script.Parent.Parent:WaitForChild("add"):WaitForChild("TextButton").MouseButton1Down:connect(function()
if script.Parent.Parent.add.TextBox.Text ~= "" then
game.ReplicatedStorage.musicEvents.addSong:FireServer(script.Parent.Parent.add.TextBox.Text)
script.Parent.Parent.add.Visible = false
end
end)
Thank you
