Cash DevProduct not Changing Value

Trying to get the DevProduct to change my Cash value in leaderstats in studio, the pop up works and the test purchase succeeds but I can’t get it to change the value of leaderstats…

the set up
-local script in a button-

local id = 1087430974
local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer


script.Parent.MouseButton1Click:Connect(function()
	mps:PromptProductPurchase(plr, id)
end)

ServerScript

local MarketPlace = game.GetService("MarketplaceService")
local id1 = 1087430974
local id2 = 1087434852
local id3 = 1087434892
local id4 = 1087435607
local id5 = 1087435824
local id6 = 1087435918
local id7 = 1087436335

id1Reward = 100
id2Reward = 500
id3Reward = 1000
id4Reward = 2500
id5Reward = 5000
id6Reward = 10000
id7Reward = 1000000000000

MarketPlace.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == id1 then
		local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + id1Reward
		return Enum.ProductPurchaseDecision.PurchaseGranted
		
	elseif  receiptInfo.ProductId == id2 then
		local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + id2Reward
		return Enum.ProductPurchaseDecision.PurchaseGranted
1 Like

Have you tried debugging by putting a print statement or breakpoint on the line where you grant the user the cash?

1 Like

just tried it and this print is not working I think it could be that my idRewards and underlined blue because they don’t have a local Rewards =
but idk what to local them too…

if receiptInfo.ProductId == id1 then
		local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + id1Reward
		print("Sucess")
		return Enum.ProductPurchaseDecision.PurchaseGranted
		```

Does ProcessReceipt invoke? Try putting a print statement on the first line of the function.

doesn’t print this

MarketPlace.ProcessReceipt = function(receiptInfo)
	print("function worked")
	if receiptInfo.ProductId == id1 then

What type of script is your ProcessReceipt code in, and where is it located?

its in ServerScriptService and its a normal Script

Where you are defining MarketPlace, try calling GetService with : instead of .

1 Like

that was the issue! works fine now

1 Like