Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Detecting If A Player Has Brought A Developer Product Has Been Brought Not Working?

For Some Reason My Script Isnt Working And I Did Get It From A Tutorial But An Error Occurs.

The Error Is On My Server Script On Line 6 Saying "Missing Argument 1 Or Nill

It Is Located In ServerScriptService Here Is My Server Script

local MarketplaceService = game:GetService("MarketplaceService")

local productID = 1174420470

local function procces (receiptInfo)
	local Plr = game.Players:GetPlayerByUserId(receiptInfo.UserId)
	if Plr then
		print("Yes")
	else
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end

MarketplaceService.ProcessReceipt = procces

Here Is My Client Script

wait(5)
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local productID = 1174420470  -- Change this to your developer product ID

-- Function to prompt purchase of the developer product
local player = Players.LocalPlayer
MarketplaceService:PromptProductPurchase(player, productID)

1 answer

Try?

-- button script
MPS = game:GetService("MarketplaceService")
id = 468786137 -- replace with your ID
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
 MPS:PromptProductPurchase(player, id)
end)

 --  Script In ServerScriptService:

local MPS = game:GetService("MarketplaceService")

MPS.ProcessReceipt = function(receiptInfo)
 if receiptInfo.ProductId == 0 then -- replace "0" with your ID 
  local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
  player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1000
  return Enum.ProductPurchaseDecision.PurchaseGranted
  
 elseif receiptInfo.ProductId == 0 then -- replace "0" with your ID 
print("Bought DevProduct")
 end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.