For some reason, I get an error that this isn’t for sale when the button is pressed, and the productID is 100 accurate.
Here’s the code:
local MarketplaceService = game:GetService("MarketplaceService") -- localscript
local Players = game:GetService("Players")
local productID = 1188308500
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(player, productID)
end)
-- script in serverscriptservice
game.MarketplaceService.ProcessReceipt = function(reciptInfo)
local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId)
if reciptInfo.ProductId == 1188308500 then
print (plr.Name .. "just bought " .. reciptInfo.ProductId)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
-- paste if statement and productID
end
Make sure you identify what the product is. If it is a gamepass, make sure it is PromptGamePassPurchase instead. If it’s a product such as a hat/clothing, use PromptProductPurchase.
You seem to be selling a developer product. So PromptProductPurchase is correct. Are you sure you edited the right game on the website? As far as I’m aware you can only sell developer products that exist for the game you’re in.
Hmm…i would check if the developer product was made for the right game. I don’t see any errors on your script. Also, it might be that the item isn’t actually for sale, like the error message said. So maybe configure the product and make sure there’s nothing wrong with it. Hope this helps.
Yea for some reason, even though it was made for the exact same game, the studio didn’t recognize products made on the website, but when I recreated it in the studio it worked.
Hi, I need help with this… My products were made in studio and are correctly set up. I tried scripts from 3 different tutorials (1 from 2 years ago, 1 from last year, and one from last month). None working. The heck is wrong?
Edit: Found out, it’s because apparently using :Activated doesn’t work, only MouseButton1Click does. Wow! So cool! Mobile players won’t be able to buy cash in my game. Thank you SO much Roblox.