Buy coins using robux script not working

I tried to create a system where you buy coins with robux, The buying thing works but it does not add the coins to the leaderstats and no errors too

Scripts:
This is the serverscriptservice script:

local mps = game:GetService("MarketplaceService")
local id = 1225136170
local id2 = 1225390598
local id3 = 1225390706
local id4 = 1225391103

local function processReceipt(receiptInfo)
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	if player then
		if receiptInfo.ProductId == id then
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1000
		end
		if receiptInfo.ProductId == id2 then
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5000
		end
		if receiptInfo.ProductId == id3 then
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10000
		end
		if receiptInfo.ProductId == id4 then
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 250000
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

This is the script inside of all the TextButtons:

local mps = game:GetService("MarketplaceService")
local id = 1225136170
local player = game.Players.LocalPlayer

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

I have copied this to all the other buttons and changed the id

This seems silly to ask, but did you make sure you called the processReceipt function? In the server script you pasted here, it does not seem like you did that.

mps.ProcessReceipt = processReceipt
1 Like

Ok thanks let me try it and see if it works

omg thanks so much,now I have a way to earn robux

2 Likes