Problem with in game purchase of UGC limited

What the hell does “something went wrong” even mean? How is any developer supposed to debug this problem? This has got to be one of the dumbest things I’ve seen from Roblox in a while.

3 Likes

:man_shrugging: wish i knew lol, it would be helpful to give at least an error code.

2 Likes

UGC Limiteds can only be sold to players via Server scripts, if they are in-experience.

2 Likes

Yes it is in experience, I’m trying to make it work rn but my lackluster scripting skills are holding me back xd

1 Like

if you, or anyone for that matter could point me in the right direction id appreciate it, tried making a click detector part bring the prompt up but I just cannot make it work.

1 Like

Was it a newly released free UGC limited? That’s the error that appears on the website where it is entirely sold out even if visually on your end it is still in stock, just due to people buying it very quick

1 Like

no its a 100 stock @500r each, none have sold

2 Likes

Try using a proximityprompt

(soz if code wacky i wrote it on mobile)

ProximityPrompt.Triggered:Connect(Player)
— do prompt here
end)

1 Like

where do i put that? on a script inside a part in the workspace? sorry im honestly clueless lol

1 Like

Make a part, add the object ProximityPrompt, place script inside of proximityprompt

local ProximityPrompt = script.Parent

there are better ways to do this this is just the quickest route

1 Like

Try a server script instead of a local script. I think I recall something about that from ages ago.

1 Like

Your issue, as stated by other developers above is that you cannot prompt UGC limits in local scripts as it is a security risk. As stated in the roblox docs: " If prompting a purchase of a Limited item, the request must come from the server or the purchase fails."

You should use a remote event (and debounces while your at it) to make sure your handling it correctly. Something like this should work:

Local script:

local button = script.Parent
local RemoteEvent = nil -- replace with pathway

button.MouseButton1Click:Connect(function()
	 RemoteEvent:FireServer()
end)

Server Script:

local RemoteEvent = nil -- replace with pathway
local market = game:GetService("MarketplaceService")
local id = <putting item id here>
local WhoCanBuyIt = {}

game.Players.PlayerAdded:Connect(function(plr) 
     task.wait(65) 
     table.insert(WhoCanBuyIt, plr.Name)
end)

market.PromptPurchaseFinished:Connect(function(plr, AssetID, DidTheyBuyIt)
     if AssetID == id and DidTheyBuyIt == true then 
         table.remove(WhoCanBuyIt, table.find(WhoCanBuyIt, plr.Name))
    end
end)

RemoteEvent.OnServerEvent:Connect(function(plr) 

  if table.find(WhoCanBuyIt, plr.Name) == nil then return end

  market:PromptPurchase(plr,id)
end)

Edit: fixed an error in my script

Edit 2: Made my debounce system account for the 60 second limitation placed on limited UGCs

2 Likes

I am also literally having the same issue right now.

Thank you for your lengthy reply, Trying to make this work with a Proximity Prompt but I’m having troubles with “replace with pathway” What exactly would the pathways be if i have the part with the proximity prompt & local script in the workspace and the server script in “ServerScriptService”

Replace with pathway is for the remote event. The remote event is an instance and so you need to make one. Often they are patented to replicated storage and given a unique name. An example of this pathway may be:

game.ReplicatedStorage.GiveLimitedItem

Where GiveLimitedItem is my Remote Event unique name. All your doing is giving the script where it exists so it can be used.

If your wanting to do this with a proximity prompt, then change the local script to:


local ProximityPrompt = nil —Place with pathway that mentions your Proximity Prompt

local RemoteEvent = nil —Replace with pathway to remote event

ProximityPrompt.Triggered:Connect(Player)
     if Player == game.Players.LocalPlayer then
          RemoteEvent:FireServer() 
     end
end)

And put this local script in StarterPlayer < StarterPlayerScripts

Trying to set it up and getting this error
image

I have a part (“Buyer”) with the proximity prompt in the workspace
image

“GiveLimitedItem” RemoteEvent in replicated storage
image

the server’s purchase script in ServerScriptService
image

and

the proximity prompt checker in StartPlayerScripts
image
(I noticed “Player” was underlined in red, could that be a problem? I also removed the other “end)” because that was giving me an error as well)

some edits. Try this:

repeat task.wait() until game.Workspace:FindFirstChild("Buyer")
local ProximityPrompt = game.Workspace.Buyer.ProximityPrompt

local RemoteEvent = game.ReplicatedStorage.GiveLimitedItem


ProximityPrompt.Triggered:Connect(function(Player)
     if Player == game.Players.LocalPlayer then
          RemoteEvent:FireServer() 
     end
end)

Error is gone but no prompt, Did i do something wrong with where I placed the rest of the scripts and stuff?

Did you wait 60 seconds?

According to UGCs to prompt a limited item, a user must be in game for 60 seconds. If you want, you could disable the prompt and re-enable it on the client when those 60 seconds are up. Here is an example:

repeat task.wait() until game.Workspace:FindFirstChild("Buyer")
local ProximityPrompt = game.Workspace.Buyer.ProximityPrompt
local RemoteEvent = game.ReplicatedStorage.GiveLimitedItem


ProximityPrompt.Enabled = false
task.wait(65)
ProximityPrompt.Enabled = true


ProximityPrompt.Triggered:Connect(function(Player)
     if Player == game.Players.LocalPlayer then
          RemoteEvent:FireServer() 
     end
end)

Oh I completely forgot about the 60 seconds xd, my bad. It seems to be working now. Thank you!

Don’t have anyone to test if the purchase actually goes through since I already own the item but once I get someone to figure that out i’ll update the post as solved.

1 Like