Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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
Ad

Answer this question