What do you want to achieve? Fix error with purchasing a in game UGC limited
What is the issue? Getting this error :
What solutions have you tried so far? Tried a different place with new ID from original, didn’t work
local button = script.Parent
local market = game:GetService("MarketplaceService")
local id = <putting item id here>
local player = game.Players.LocalPlayer
button.MouseButton1Click:Connect(function()
market:PromptPurchase(player,id)
end)
Using a button gui and a local script
and yes the game is public with 3rd party sales active.
the prompt to buy pops up and once you click purchase it gives the error
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.
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.
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
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
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