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.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