Hi, so basically I’m working on this new game, I mean experience, and I want to make it where you can type in a valid song ID into a text box and a developer product will prompt to where if you buy it, then whatever ID was in the box it will insert a new sound with that ID into the songs folder. (Sorry for the run-on sentence.)
Anyways, so my problem is that the script that I made only works in local servers. I tried it in single player and in a local server running off of my computer, and they both worked in studio. However, when I tried to use it in team test, the the song wasn’t added to the folder. I still was prompted with the dev product, but I haven’t been able to make it insert the sound itself when I buy it. Any tips?
Here’s the local script:
local MPS = game:GetService("MarketplaceService")
local PlayAudio = RPS:WaitForChild("PlayAudio")
local player = game:GetService("Players").LocalPlayer
local db = false --cooldown variable
script.Parent.MouseButton1Click:Connect(function()
if db == false then
db = true
local assetID = tonumber(script.Parent.Parent.enterID.Text) --gets the number value of the text box text
if assetID then
local success, Info = pcall(MPS.GetProductInfo, MPS, assetID) --checks if the sound id is valid
if success then
local sound = Instance.new("Sound", game.Workspace)
wait(1)
sound.SoundId = ("rbxassetid://"..assetID)
wait(1)
if sound and (sound.TimeLength > 0) then
MPS:PromptProductPurchase(player, 1171899953) --prompts the dev product
PlayAudio:FireServer(assetID)
sound:Destroy()
else
sound:Destroy()
end
else
warn("Invalid song ID!")
end
end
wait(5)
db = false
end
end)
Basically it checks whether or not the song ID in the text box is valid and then sends that ID to the server script to insert if you buy the product.
Here is the Server Script:
local MPS = game:GetService("MarketplaceService")
local ISS = game:GetService("InsertService")
local PlayAudio = RPS:WaitForChild("PlayAudio")
PlayAudio.OnServerEvent:Connect(function(player, assetID)
local function processReceipt(receiptInfo)
local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
local newsound = Instance.new("Sound", game.Workspace.songs) --inserts new sound into the songs folder
newsound.SoundId = ("rbxassetid://"..assetID)
newsound.Name = "playerSound"
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MPS.ProcessReceipt = processReceipt
end)
I don’t know why this only works in local servers and not team test or in-game, but I would appreciate any feedback and support. Thanks!