Developer Product Script Issue

Ello, I was experimenting different scripts I can make with Studio and some reason this script I made doesn’t work.

Code:

Script:
MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.ProcessReceipt = function(ReciptInfo)
	local Player = game.Players:GetPlayerByUserId(ReciptInfo.PlayerId)
	if ReciptInfo.ProductId == 3688332296 then
		Player.LeaderStats.Cash.Value = Player.LeaderStats.Cash.Value + 1000
	end
end

Local Script:
local MarketplaceSerivce = game:GetService("MarketplaceService")
local BuyCashButton = script.Parent
local DeveloperProduct1 = 3688332296

BuyCashButton.MouseButton1Click:Connect(function()
	MarketplaceSerivce:PromptPurchase(game.Players.LocalPlayer, DeveloperProduct1)
end)

No errors in the output.

1 Like

Is this a localscript? Where is this script?

1 Like

The local script is in the GUI and the Script is in server script service.

1 Like

What is the issue? Does it not prompt the product?

1 Like

I believe this only works in a Script.

1 Like

It does, but it doesn’t give the cash amount.

1 Like

It prompt’s in a local script. Only issue is after purchasing the item I don’t get cash

1 Like

I don’t think you have a place to send receipt hold on

1 Like

Put this at the end of the function in the local script and try:

return Enum.ProductPurchaseDecision.PurchaseGranted
2 Likes

Do you mean in the receipt ? ADDING CHARACTERS

1 Like

Watching a video on it. I might of figured a new way out.

BuyCashButton.MouseButton1Click:Connect(function()
	MarketplaceSerivce:PromptPurchase(game.Players.LocalPlayer, DeveloperProduct1)
MarketplaceService.PromptProductPurchaseFinished:Connect(the server function)

end)
1 Like

Add this to end of server script too:

MarketplaceService.ProcessReceipt = ProcessReceipt
1 Like

Here is my new server script. Still ain’t working, it won’t print it when I purchase the product.

local MarketplaceService = game:GetService("MarketplaceService")
local Player = game:GetService("Players")
local ProductId = 3688332296

MarketplaceService.ProcessReceipt = function(Receipt)
	local Player = game.Players:GetPlayerByUserId(Receipt.PlayerId)
	if not Player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	if Receipt.ProductId == 3688332296 then
		print("Thank you for buying!")
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
1 Like

Can I see the local script? Also did you add

MarketplaceService.ProcessReceipt = ProcessReceipt

to the end of the script?

2 Likes

Local script is working and included it in my post above. Also I changed the script with a video and now it says UserID is a nil value. Any solutions?

local MarketplaceService = game:GetService("MarketplaceService")


local function ProcessReceipt (ProcessReceiptInfo)
	local Player = game:GetService("Players"):GetPlayerByUserId(ProcessReceiptInfo.UserID)
	if not Player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	print("Player bought product!")
	Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 1000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

MarketplaceService.ProcessReceipt = ProcessReceipt()
2 Likes

Where I did

 local Player = game:GetService("Players"):GetPlayerByUserId(ProcessReceiptInfo.UserID)

The parameter of UserID is a nil value. Solutions?

2 Likes

I also tried doing “PlayerId” that also said nill value

2 Likes

… I kept watching the video and when I copy pasted his code it worked but mine looked exact same after I watched his video THEN I REALIZE I NEEDED THE ProcessReceipt to be capital and spaced out and holy cow. Atleast it works.

1 Like

bruh loll

At least you figured it out yourself, that’s improvement!

1 Like