Error when selling limited UGC in game

Hello developers,

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:
image

In game:
image

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)

Thank you in advance for your answers!

1 Like

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

1 Like

Oh I did not add anything like that. I am going to try it.
Thanks!

2 Likes

Ok, here is the new script:

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?

And you set up this limited correctly?

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?

1 Like

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.

1 Like

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?

3rd party sales are on, yes. I also tried the pcall function method

local success, err = pcall(function()
						mps:PromptPurchase(player, 14945527508, true)
					end)
					
					if success then
						warn("Successfully prompted UGC item")
					else
						warn(err)
					end
					debounce = true
					wait(2)
					debounce = false

And it says it was successfully prompted
image

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.

I removed the true value from the PromptPurchase and it’s still not working. Could this error be caused by Roblox?

Didn’t Roblox have an update to combat this? I’m not entirely sure though.

They did have an update, but there might be another bug again?

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.

Oh I did not know about that. Thanks for telling me!

I read the post about it and if I understand correctly, you can sell, but only what I am authorised to sell.

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

After doing some research and stuff, I found out that a lot of other people are having issues with this.

Someone else also provided screenshots for me to show the same problem in different games.
image

Edit: They finally fixed it! It works now!

1 Like

@OfficialPogCat They finally fixed it! It works perfectly now! Thank you for your help.

1 Like

Nice! Just make sure to make one of the replies a solution so people don’t comment on this topic that has a solution! Glad it works for you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.