You can see the documentation for ProcessReceipt here
You don’t check the enumeration, you have to return the enumeration as stated in the documentation page. You can do something like this:
local MPS = game:GetService("MarketplaceService")
function MPS.ProcessReceipt(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if player then
player.leaderstats.Coinn.Value = player.leaderstats.Coin.Value + 100
return Enum.ProductPurchaseDecision.PurchaseGranted
end
return Enum.ProductPurchaseDecision.NotProcessedYet
end
Didn’t work. Just to be more clear, if something was completely out of line, here is the script that I have right now:
local MarketPlaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local id = "1006738178"
script.Parent.MouseButton1Click:Connect(function()
game.MarketplaceService:PromptProductPurchase(player, id)
end)
local MPS = game:GetService("MarketplaceService")
function MPS.ProcessReceipt(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if player then
player.leaderstats.Coinn.Value = player.leaderstats.Coin.Value + 100
return Enum.ProductPurchaseDecision.PurchaseGranted
end
return Enum.ProductPurchaseDecision.NotProcessedYet
end
Sorry for such a late reply
Normal script inside ServerScriptService
–Read over the script and change the ’ ’ for your case
local MarketPlaceService = game:GetService("MarketplaceService")
local product = 'id of the product'
local function processReceipt(receiptInfo)
if receiptInfo.ProductId == product then
local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
player.leaderstats.'your leaderstat here'.Value = player.leaderstats.'your leaderstat here'.Value + 'value you want to add'
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
MarketPlaceService.ProcessReceipt = processReceipt
And this is what you should have inside a LocalScript inside your button
local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productId = 'your product id'
script.Parent.MouseButton1Down:Connect(function(promptPurchase)
local player = Players.LocalPlayer
MarketPlaceService:PromptProductPurchase(player, productId)
end)
If you want to add more DevProducts then you would just add an if… to the function under the first end
local mkp = game:GetService("MarketplaceService")
mkp.PromptProductPurchaseFinished:Connect(function(userId,product,purchased)
local player = game.Players:GetPlayerByUserId(userId)
if purchased then
player.leaderstats.Coinn.Value = player.leaderstats.Coinn.Value +1
end
end)
game.ReplicatedStorage:WaitForChild("Buy1Coin").OnServerEvent:Connect(function(player)
mkp:PromptProductPurchase(player,1006738178)
end)