Why ProcessReceipt doesnt work in the game but works in studio

Hello! I have a script that gives cash when player purchased a product. It works perfectly in studio but doesnt work in game. Is there any way i messed up something?
Script:

local MPS = game:GetService(“MarketplaceService”)
local players = game:GetService(“Players”)

local productIds = {

[1578927239] = 25, --25 is cash and 1579041943 is the ID
[1578928176] = 75,
[1578929804] = 125,
[1578930229] = 175,

}

MPS.ProcessReceipt = function(receiptInfo)
local id = receiptInfo.ProductId
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then return Enum.ProductPurchaseDecision.NotProcessedYet end
local productFromTable = productIds[id]
if productFromTable == nil then return Enum.ProductPurchaseDecision.NotProcessedYet end
player.leaderstats.Cash.Value += productFromTable
return Enum.ProductPurchaseDecision.PurchaseGranted
end

1 Like

What exactly is the issue?

  • Are the DevProducts in that game’s universe?
  • Is this in a server script?
  • Do you have this in more than 1 script?
2 Likes

1.Yes they’re are in that game’s universe
2.Yes this is in a server script
3.Yes, this one still in a gui frame inside, there are also the buttons that have an int value and there are also again the ids inside, there are a total of 4 buttons, with the ids.

Script from gui:
local mps = game:GetService(“MarketplaceService”)
local players = game:GetService(“Players”)

local plr = players.LocalPlayer

local frame = script.Parent

for i, button in pairs(frame:GetChildren()) do
local productId = button:FindFirstChild(“ProductId”)
if productId then
button.MouseButton1Click:Connect(function()
mps:PromptProductPurchase(plr, productId.Value)
end)
end
end

When you say it doesn’t work in the game, you tried purchasing a DevProduct in-game?

Is there any errors that were logged?

Where is the script for processing receipt parented?

2 Likes
  1. Yes, I did
  2. thats all what was there after purchase (image). There is a donation board, maybe thats the issue?
  3. ServerScriptService

hi, you can try to create different functions for each prductId:

local products = {}
products[id] = function()
return Yourcodeheretogive cash
end

You can after check if the table has that product by
if products[id] and run the function.

2 Likes

What does line 74 of that script look like?