Code isn't working, it is a script in ServerScriptService. it is supposed to award cash upon purchase of Developer Product (not in leaderstats, it can be seen at the bottom at the screen using a text label) and wins which is in leaderstats. Can someone take a look at the code? Thanks!
local mps = game:GetService("MarketplaceService") mps.ProcessReceipt = function(receiptInfo) if receiptInfo == 1208410513 then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.Cash.value = player.Cash.value + 100 return Enum.ProductPurchaseDecision.PurchaseGranted end if receiptInfo == 1342774613 then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.Cash.value = player.Cash.value + 1000 return Enum.ProductPurchaseDecision.PurchaseGranted end if receiptInfo == 1342770170 then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.Cash.value = player.Cash.value + 300 return Enum.ProductPurchaseDecision.PurchaseGranted end if receiptInfo == 1342771507 then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.Cash.value = player.Cash.value + 500 return Enum.ProductPurchaseDecision.PurchaseGranted end if receiptInfo == 1343023770 then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.leaderstats.Wins.value = player.leaderstats.Wins.value + 30 return Enum.ProductPurchaseDecision.PurchaseGranted end if receiptInfo == 1343022593 then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.leaderstats.Wins.value = player.leaderstats.Wins.value + 10 return Enum.ProductPurchaseDecision.PurchaseGranted end end
@9mze meant only in line 4, 9, 14, 19, 24, and 29. Also, instead of individual conditions, put all of them in one condition using elseif
every condition because if one condition returned, the other conditions after that condition won't run anymore. Also use .Value
instead of .value
with a small v.
local Players = game:GetService("Players") local mps = game:GetService("MarketplaceService") mps.ProcessReceipt = function(receiptInfo) local player = Players:GetPlayerByUserId(receiptInfo.PlayerId) if player then if receiptInfo.ProductId == 1208410513 then player.Cash.Value += 100 elseif receiptInfo.ProductId == 1342774613 then player.Cash.Value += 1000 elseif receiptInfo.ProductId == 1342770170 then player.Cash.Value += 300 elseif receiptInfo.ProductId == 1342771507 then player.Cash.Value += 500 elseif receiptInfo.ProductId == 1343023770 then player.leaderstats.Wins.Value += 30 elseif receiptInfo.ProductId == 1343022593 then player.leaderstats.Wins.Value += 10 end else return Enum.ProductPurchaseDecision.NotProcessedYet end return Enum.ProductPurchaseDecision.PurchaseGranted end