So I have been trying to make a script that sells players a free limited UGC item. The original sale of this item is only available in the experience. The product purchase works in studio but not in game.
In studio:
In game:
Here’s the script:
local mps = game:GetService("MarketplaceService")
local debounce = false
game.ReplicatedStorage.BuyUGC.OnServerEvent:Connect(function(player)
if debounce == true then return end
if player:IsInGroup(16863310) then
if player:WaitForChild("leaderstats"):WaitForChild("AOrbe").Value >= 500 then
if game.MarketplaceService:GetProductInfo(14945527508).Remaining > 0 then
mps:PromptPurchase(player, 14945527508, true)
warn("UGC purchase prompted")
debounce = true
wait(2)
debounce = false
end
end
end
end)
Are you accounting for the 60 second limitation that players must be in game for 60 seconds before your allowed to prompt them the item? If not, I would make sure to follow this limitation and make sure the player is in your game for longer then 60 seconds before your script prompts it to them
game.Players.PlayerAdded:Connect(function(player)
local joincooldown = Instance.new("NumberValue")
joincooldown.Name = "JoinCooldown"
joincooldown.Parent = player
for i = 60,0,-1 do
joincooldown.Value = i
wait(1)
end
end)
local mps = game:GetService("MarketplaceService")
local debounce = false
game.ReplicatedStorage.BuyUGC.OnServerEvent:Connect(function(player)
if debounce == true then return end
if player:IsInGroup(16863310) then
if player:FindFirstChild("JoinCooldown").Value == 0 then
if player:WaitForChild("leaderstats"):WaitForChild("AOrbe").Value >= 500 then
if game.MarketplaceService:GetProductInfo(14945527508).Remaining > 0 then
mps:PromptPurchase(player, 14945527508, true)
warn("UGC purchase prompted")
debounce = true
wait(2)
debounce = false
end
end
else
player.PlayerGui.UGC.Frame.TextLabel.Text = "YOU NEED TO WAIT "..player:FindFirstChild("JoinCooldown").Value.."s TO BUY THIS UGC!"
wait(2)
player.PlayerGui.UGC.Frame.TextLabel.Text = ""
end
end
end)
But it still gives the same error in the game. Am I doing something wrong?
You can check by running this line of code and making sure that you can sell it in your own game:
print(game:GetService("MarketplaceService"):GetProductInfo(14945527508).CanBeSoldInThisGame)
--If prints true, you good, if false, it can't be prompted in game
Other then that, in the roblox appilication, can you check the logs and see if there are any errors on the server side about this. Is your game public or private, and if private, is that a possible issue your facing?
The print(game:GetService("MarketplaceService"):GetProductInfo(14945527508).CanBeSoldInThisGame)
prints out true, and yes, the game is public. There is no error in the logs as well.
Try pcalling it… Its weird that it’s erroring on you. As long as your following the limits, then your code should work?
Limits are…
9 successful purchases per minute per user.
1 purchase request every 2 seconds per item per user.
A maximum of 3 successful purchases per user per item.
For in-experience purchases, users must be in the experience for 60 seconds to successfully complete a purchase.
local success, Error = pcall(function()
mps:PromptPurchase(player, 14945527508)
end)
if success then
print("Prompt Success")
else
print("Didn't prompt purchase.. Error: "..Error)
end
We will see if this gives us some more information on the issue.
Edit: I haven’t asked yet, but 3rd party sales on right?
Yea Idk. My only other idea is to remove the true in this line.
Only reason why I say this is because Limited prompts are much more secure and tight, and have limits. And personally have never used the equipIfPurchased on a limited prompt or really ever. It doesn’t make sense but its my only idea. Other then that, yea Idk what to tell you other then try to find out information or any warnings that could suggest what is wrong.
No I mean, an update to combat selling UGC items in-experience rather than on the marketplace. I’m pretty sure it’s against ToS now too, I could be wrong, didn’t read much into it. Defo worth researching.
This policy is not active and in fact is revoked. So you are not subject to following those Policy changes on selling items. You should be ok to sell this limited item