I’m working on a donation system for my game. I thought this would be simple, and normally it should be; but then I ran into a glitch that had me staring helplessly at the screen for 30 minutes.
Whenever I try to purchase one of the donations, it tells me the developer product is not currently for sale.
I looked for solutions online and found out that most common cause of this error is using PromptPurchase
instead of PromptProductPurchase
. I noticed I made that mistake, but then I fixed that. It was still broken; the output was blank.
I then:
- Double checked all the IDs to make sure they were entered properly (they were)
- Double checked the arguments I was passing over in the
PromptProductPurchase
function along with checking the API reference to make sure I was sending over the right things (I was)
At this point I’ve run out of ideas. Can anyone figure out what’s going on?
local rst = game:GetService("ReplicatedStorage")
local mks = game:GetService("MarketplaceService")
local assetsFolder = rst.Assets
local plr = game.Players.LocalPlayer
local ui, donateUI, viewButton = nil, nil, nil
local donateOptionButtons = {}
local uiOpen = false
local productIDs = {
1185279848,
1185279869,
1185279887,
1185279903,
1185279915,
1185279930
}
local productInfoDictionary = {}
local donationButtons = {}
local totalDonationOptions = #productIDs
local function toggleUI()
uiOpen = not uiOpen
donateUI.Visible = uiOpen
end
local function close()
donateUI.Visible = false
end
for i=1, totalDonationOptions do
local button = assetsFolder.UI.Donation.DonationOption:Clone()
button.LayoutOrder = i
local productID = productIDs[i]
print(productID)
button.MouseButton1Click:Connect(function()
mks:PromptProductPurchase(plr, productID)
end)
donateOptionButtons[i] = button
local productInfo = mks:GetProductInfo(productID, Enum.InfoType.Product)
productInfoDictionary[i] = productInfo
button.Text = "Donate R$"..productInfo.PriceInRobux
end
ui = plr.PlayerGui:WaitForChild("UI")
donateUI = ui.Donation
viewButton = ui.DonateButton
for i,button in pairs(donateOptionButtons) do
button.Parent = donateUI.Options
end
donateUI.Options.UIGridLayout.CellSize = UDim2.new(1, 0, 1/totalDonationOptions, -5)
donateUI.Close.MouseButton1Down:Connect(close)
viewButton.MouseButton1Down:Connect(toggleUI)